How to write a UTF-8 file with Java?

前端 未结 9 1265
半阙折子戏
半阙折子戏 2020-11-22 16:17

I have some current code and the problem is its creating a 1252 codepage file, i want to force it to create a UTF-8 file

Can anyone help me with this code, as i say

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 16:49

    var out = new java.io.PrintWriter(new java.io.File(path), "UTF-8");
    text = new java.lang.String( src || "" );
    out.print(text);
    out.flush();
    out.close();
    

提交回复
热议问题