标签:指定 http pre lin ring 字符 NPU 输出内容 操作
可以指定输出内容的字符集不加装饰器:
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("操作异常");
}
标签:指定 http pre lin ring 字符 NPU 输出内容 操作
原文地址:https://blog.51cto.com/14437184/2424581