[求助]java下载文件出错
try { URL url = new URL(http://172.28.24.229/test.txt); DataInputStream in=new DataInputStream(url.openStream()); ObjectOutputStream outputStream=new ObjectOutputStream(new FileOutputStream("f:\\out.txt")); byte bt; while(in.available()!=0) { bt=in.readByte(); outputStream.writeByte(bt); } in.close(); outputStream.close();// 下载完毕 } catch(Exception eurl) { //first_url.setText("出错了"); }
以上代码功能就是下载http://172.28.24.229/test.txt到本地的F盘out.txt
test.txt里面的内容是“hellow”
可是我运行的结果得到out.xt里面的内容是 "? whellow"
怎么会多出"? w"呢