urlconnection.java
来自「J2EE第三章实例1」· Java 代码 · 共 31 行
JAVA
31 行
import java.io.*;
import java.net.*;
public class urlconnection {
static FileOutputStream fos;
static URL url;
static URLConnection urlConnection;
static InputStream is;
static int i;
public static void main(String args[]) {
try {
fos = new FileOutputStream("index.html");
url = new URL("http://www.yahoo.com.cn/index.html");
urlConnection = url.openConnection();
is = urlConnection.getInputStream();
i = is.read();
while(i > 0) {
fos.write(i);
i = is.read();
}
fos.close();
is.close();
}
catch (IOException e) {
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?