This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

a bug of java.io.File ?


hello all,
java.io.File of libgcj.so.7(gcj 4.1) seems only support fileName in
UTF-8 encoding ,
but not work well in other encoding.such as gbk
that is my code (list all the fileName of a directory):
when the direcotry contains a file named in other encoding(not UTF-8,
eg,GBK),a NULLPointException is throwed in performlist() function while
invoking file.listFiles().
and file.list() could not recognize files which encoded in other
encoding ,and only return null.
how to solve this problem ? as My application compiled by gcj can not be
used in a NOT UTF-8 locale.

Thanks with much appreciation !

import java.io.File;
public class gcc {
public static void main(String[] args) {
File file = new File("/home/bbskill/Temp/java/tests/libjava");
File[] files = file.listFiles();
System.out.println(files);
for(int i = 0 ; i< files.length;i++)
System.out.println(files[i].getName());

String[] str = file.list();
for(int i = 0 ;i< str.length;i++)
System.out.println(str[i]);
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]