Chinese encoding issue while listing files

Posted by Null Pointer on Stack Overflow See other posts from Stack Overflow or by Null Pointer
Published on 2010-03-11T09:25:24Z Indexed on 2010/03/12 1:27 UTC
Read the original article Hit count: 504

Filed under:
|
|
|

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 "??????".

© Stack Overflow or respective owner

Related posts about java

Related posts about encoding