character encoding - All inclusive Charset to avoid "java.nio.charset.MalformedInputException: Input length = 1"? -
I am creating a simple wordpress program in Java that reads through the directory's text-based files.
However, I continue to get the error:
java.nio.charset.MalformedInputException: Input Length = 1 From this line of code:
BufferedReader Reader = Files.newBufferedReader (file, Charset.forName ("UTF-8")); I know I might get it because I used a charset , which did not include some of the text files, some of which others The characters were included languages But I want to include those characters. I learned later that charset is optional and is used only for more efficient reading of the files, so I changed the code: BufferedReader Reader = Files.newBufferedReader (file); But some files still throw MalformedInputException . I do not know why I was wondering if there is an all-encompassed charset which will allow me to read text files with many different types of characters ? Thank you.
You probably want a list of supported encodings for each file, try each encoding instead, maybe Starting with UTF-8 every time you capture MalformedInputException , try the next encoding.
Comments
Post a Comment