java - how to avoid Files.lines() throwing MalformedInputException on japanese text? -


my code throws exception

exception in thread "main" java.io.uncheckedioexception: java.nio.charset.malformedinputexception: input length = 1 @ java.io.bufferedreader$1.hasnext(bufferedreader.java:574) @ java.util.iterator.foreachremaining(iterator.java:115) @ java.util.spliterators$iteratorspliterator.foreachremaining(spliterators.java:1801) @ java.util.stream.referencepipeline$head.foreachordered(referencepipeline.java:590) 

when executing line

files.lines(in.topath()).foreachordered(new consumer<string>() {     @override     public void accept(string s) {         //stuff     }); 

the file causes behaviour when opened in notepad++ shows enter image description here

of course text garbled because of encoding, if select "convert utf-8" "encoding" menu shows correctly

enter image description here

which makes me assume utf-8 correct encoding, according java documentation files.lines() uses utf-8 encoding default (it's equivalent of files.lines(path, standardcharsets.utf_8)) yet still breaks when reading files japanese text, how should handle this?


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -