首页上一页 1 下一页尾页 1 条记录 1/1页
程序不知道该填写什么包,比如下面的代码,该在引入类的时候填写什么包
发表在Java图书答疑
2013-11-16
是否精华
是
否
版块置顶:
是
否
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class Test {
public static void main(String[] argc) {
URL url = null;
FileOutputStream fos = null;
InputStream is;
try {
for (int i = 0; i < 1; i++) {
url = new URL("http://www.phpchina.com/");
byte bytes[] = new byte[1024 * 1000];
int index = 0;
is = url.openStream();
int count = is.read(bytes, index, 1024 * 100);
while (count != -1) {
index += count;
count = is.read(bytes, index, 1);
}
fos = new FileOutputStream("phpchina.html");
System.out.println(index);
fos.write(bytes, 0, index);
is.close();
fos.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class Test {
public static void main(String[] argc) {
URL url = null;
FileOutputStream fos = null;
InputStream is;
try {
for (int i = 0; i < 1; i++) {
url = new URL("http://www.phpchina.com/");
byte bytes[] = new byte[1024 * 1000];
int index = 0;
is = url.openStream();
int count = is.read(bytes, index, 1024 * 100);
while (count != -1) {
index += count;
count = is.read(bytes, index, 1);
}
fos = new FileOutputStream("phpchina.html");
System.out.println(index);
fos.write(bytes, 0, index);
is.close();
fos.close();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}