?? first.java
字號:
import java.io.*;
import java.net.*;
import java.io.InputStreamReader;
public class first
{
public static void main(String[] args) throws IOException
{
String http = "http://finance.sina.com.cn/";
URL url=null;
long start_time=System.currentTimeMillis();
long end_time;
try{
url = new URL(http);
}catch(MalformedURLException e){
System.out.println("Ip isn't valid!");
}
InputStream inputStream = url.openStream();
try{
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter("d:\\java\\cx\\hw1.html")));
String s = "";
while ((s = bufferedReader.readLine()) != null) {
out.write(s);
}
end_time=System.currentTimeMillis();
out.write("<br>The time used is:"+(end_time-start_time));
out.flush();
}catch(EOFException e){
System.err.println("End of stream");
}
inputStream.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -