Java Native language Application Doesnt work outside IDE

前端 未结 2 1845
臣服心动
臣服心动 2021-01-27 14:02

I have a program developed under java with netbeans. It has a text pane that takes text written in non English language and do some operation including save open new.....

<
2条回答
  •  天命终不由人
    2021-01-27 14:39

    Try changing your reading logic to use InputStreamReader which allows setting encoding:

    InputStreamReader inputStreamReader = 
      new InputStreamReader(new FileInputStream (file), "UTF-8" );
    

    Also change your writing logic to use OutputStreamWriter which allows setting encoding:

    OutputStreamWriter outputStreamWriter = 
      new OutputStreamWriter(new FileOutputStream (file), "UTF-8" );
    

提交回复
热议问题