Chinese encoding issue while listing files
- by Null Pointer
I am running a Java application on a Solaris10 with Chinese. Now there are some files in a directory with chinese filenames. When I do files = new File(dir).list() where "dir" is the parent directory containing that chinese file, I get the result filename files[0] as ?????(some junk characters).
Now the deal is that my programs file.encoding property is already set to GBK and I also do Charset.isSupported("GBK") and it returns true too. So where could be the problem. I am running out of ideas.
NOTE: I am not trying to print the filename anywhere or copy the file or something. I am simply openeing a stream to it, something like below:
files = new File(dir).list();
new FileInputStream(files[0]);
Now this gives me a FileNotFoundExcpetion, so I debug just to find that value inside files[0] is "??????".