[英]Java Printwriter Encoding UTF-8
File file2 = new File("output.txt");
FileWriter fileWriter = new FileWriter(file2, true);
PrintWriter out = new PrintWriter(fileWriter);
out.println("üçı");
out.close();
My code is here. 我的代码在这里。 I want to write to the file with encode UTF-8. 我想用UTF-8编码写入文件。 Please help. 请帮忙。
Try this please. 请尝试这个。 this must work for you(i hope) 这必须为您工作(我希望)
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(file2), Charset.forName("UTF-8"));
PrintWriter out = new PrintWriter(outputStreamWriter);
out.print("سلام");
maybe this will solve your problem. 也许这可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.