我想从下面的页面(http://l2.io/ip或其他)中读取我的IP地址,使用javascript将他保存在我的变量"myIp"中.
function getMyIP() {
var myIp;
...
return myIp;
}
Run Code Online (Sandbox Code Playgroud)
你怎么办?
如果我写这个代码,我把它作为输出 - >首先:然后是其他行
try {
BufferedReader br = new BufferedReader(new FileReader(
"myFile.txt"));
String line;
while (line = br.readLine() != null) {
System.out.println(line);
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我怎么能避免呢?
"finally"和"catch"之后写的有什么区别?
例如:
public boolean example() {
try {
// Code
} catch (RuntimeException e) {
// Code
} finally {
return true;
}
}
public boolean example() {
try {
// Code
} catch (RuntimeException e) {
// Code
}
return true;
}
Run Code Online (Sandbox Code Playgroud) 如何制作我的java应用程序的打印屏幕?
saveScreen.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
...
}
});
Run Code Online (Sandbox Code Playgroud) java ×3
exception ×1
filereader ×1
ip ×1
javascript ×1
jbutton ×1
printscreen ×1
try-catch ×1
unicode ×1