I\'m struggling with a strange file name encoding issue when listing directory contents in Java 6 on both OS X and Linux: the File.listFiles()
and related metho
I suspect that you just have to instruct javac
what encoding to use to compile the .java
file containing the special characters with since you've hardcoded it in the source file. Otherwise the platform default encoding will be used, which may not be UTF-8 at all.
You can use the VM argument -encoding
for this.
javac -encoding UTF-8 com/example/Foo.java
This way the resulting .class
file will end up containing the correct characters and you will be able to create and list the correct filename as well.