1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 将字符串写入文件出现中文乱码的解决办法

将字符串写入文件出现中文乱码的解决办法

时间:2023-01-04 06:17:14

相关推荐

将字符串写入文件出现中文乱码的解决办法

public static void main(String[] args) throws IOException {Writer writer = null;try{String content = "种瓜得瓜种豆得豆";//要写入的字符串File file = new File("D://1.txt");//创建文件的地址writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));writer.write(content);writer.flush();} catch (IOException e) {e.printStackTrace();}finally {if(writer != null){writer.close();}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。