不知道这段程序问题出在哪里,编译没错误,可执行的时候就是没反应 写出抛出错误先 MalformedURLException 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把那个网址改成http://www.tom.com/index.html。这样java就知道用的协议是http public static void main(String args[]) { char[] bytes; try { File file = new File("g:/a.html"); URL url = new URL("http://www.tom.com/index.html"); int byteSize = 1024; System.out.println("dfsdf"); int num; bytes = new char[byteSize]; BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); BufferedWriter out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(file))); while ((num = in.read(bytes, 0, byteSize)) != -1) out.write(bytes, 0, num); System.out.println("写了" + num + "个"); } catch (Exception e) { e.printStackTrace(); } } 请问file有这样构造方法吗??File file=new File(URL url);上次方法只能下载文本文件,下载exe文件就会出错该怎么样下载exe文件呢 好像是因为用了Reader, Writer的缘故吧,因为它们是面向字符的二进制文件要用面向字节流的InputStream, OutStream java 调用ocx JTable 修改某行后, 行数据验证失败(如:主键冲突) , 禁止选取其它行 怎么修改应用程序图标? 关于printwriter不同的构造方法问题 队列的问题 为什么用FileReader读取.doc文档会出现乱码?如何解决? 请教一个JTextPanel显示网页的问题 急,在线等! 求助:关于Component 的add方法 牛人进,为什么Thread(Runnable)我怎么也传不进? 希望得到大家的指点提供思路和方法!!!!!!!!!!!!!! 请帮我看看我哪里出错了
这样java就知道用的协议是http public static void main(String args[]) {
char[] bytes;
try {
File file = new File("g:/a.html");
URL url = new URL("http://www.tom.com/index.html");
int byteSize = 1024;
System.out.println("dfsdf");
int num;
bytes = new char[byteSize];
BufferedReader in =
new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter out =
new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(file)));
while ((num = in.read(bytes, 0, byteSize)) != -1)
out.write(bytes, 0, num);
System.out.println("写了" + num + "个");
}
catch (Exception e) {
e.printStackTrace();
} }
上次方法只能下载文本文件,下载exe文件就会出错
该怎么样下载exe文件呢
二进制文件要用面向字节流的InputStream, OutStream