All inclusive Charset to avoid “java.nio.charset.MalformedInputException: Input length = 1”?

前端 未结 10 1367
醉话见心
醉话见心 2020-11-30 00:48

I\'m creating a simple wordcount program in Java that reads through a directory\'s text-based files.

However, I keep on getting the error:

java.nio.c         


        
10条回答
  •  遥遥无期
    2020-11-30 01:26

    You probably want to have a list of supported encodings. For each file, try each encoding in turn, maybe starting with UTF-8. Every time you catch the MalformedInputException, try the next encoding.

提交回复
热议问题