可以指定输出内容的字符集

不加装饰器:
OutputStreamWiter os = new OutputStreamWriter(new FileOutputStream("D:/d/baidu"),"UTF-8"); //不指定字符集,将默认为工程字符集

加装饰器:
BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:/d/baidu"),"UTF-8") );

try(BufferedReader reader=new BufferedReader(new InputStreamReader(new URL("http://www.baidu.com").openStream(),"UTF-8")); BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:/d/baidu.html"),"UTF-8")); //不指定字符集,默认是工程字符集 ){ String s; while((s=reader.readLine())!=null) { writer.write(s); writer.newLine(); writer.flush(); }}catch(IOException e){ System.out.println("操作异常");}