例如:司薇等汉字,
代码如下:
filename = new String(filename.getBytes("utf-8"),"UTF-8");
//构造URL
URL url = new URL(replace);
//打开连接
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/4.0(compatible;MSIE 5.0;Windows NT;DigExt)");
//输入流
is = conn.getInputStream();
//1k的数据缓冲
byte[] bs = new byte[1024];
int len;
//输出的文件流
os = new FileOutputStream(filename,true);
//开始读取
while((len = is.read(bs)) != -1){
os.write(bs,0,len);
}