Java Native language Application Doesnt work outside IDE

前端 未结 2 1857
臣服心动
臣服心动 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:41

    The root problem is that your current application is reading the file using the "platform default" character set / character encoding. This is obviously different when you are running from the command line and from NetBeans. In the former cause, it depends on the locale settings of the host OS or the current shell ... depending on your platform. In NetBeans, it seems to default to UTF-8.

    @Andrey Adamovich's answer explains how to specify a character encoding when opening a file using a file reader or adapting a byte stream using an input stream reader.

提交回复
热议问题