不知道这段程序问题出在哪里,编译没错误,可执行的时候就是没反应 写出抛出错误先 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 swing程序在linux直接运行 今天解决了一个操蛋的问题! 关于Socket的问题 请帮帮小弟一个忙 【新手提问】请问怎么给JFrame界面弄个背景?还有怎么设置成自己想设的鼠标? yyyyMMdd格式的日期字符串比较 如何引用Vector类的中的元素? 在Intellij IDEA中如何调用swing explorer插件 数据库查询结果分页显示问题 好消息,本网站的分可以按比例兑换实币 希望得到大家的指点提供思路和方法!!!!!!!!!!!!!! 请帮我看看我哪里出错了
这样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