java
encoding
ai_generated
true
java.nio.charset.MalformedInputException: Input length = 1 — non-ASCII path or filename
ID: java/malformedinputexception-nonascii-path
85%Fix Rate
88%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 17 | active | — | — | — |
Root Cause
Java Files.readAllLines() or similar API throws MalformedInputException when file path or content contains Korean/CJK and no charset is specified.
genericWorkarounds
-
95% success Explicitly specify StandardCharsets.UTF_8 in all file read/write operations
Files.readAllLines(path, StandardCharsets.UTF_8) // never rely on default charset
Sources: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html
-
88% success Set -Dfile.encoding=UTF-8 JVM argument and use InputStreamReader with explicit charset
java -Dfile.encoding=UTF-8 -jar app.jar // also use new InputStreamReader(is, StandardCharsets.UTF_8)
Sources: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/InputStreamReader.html
Dead Ends
Common approaches that don't work:
-
Wrap in try-catch and skip the file
90% fail
Silently skipping files with Korean names hides real data; does not fix the encoding issue
-
Convert filename to ASCII with Normalizer
85% fail
Normalizer handles decomposition, not transliteration; Korean chars have no ASCII equivalent