📄 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 + -