a bug of java.io.File ?

bbskill bbkills@tom.com
Sun Aug 21 13:10:00 GMT 2005


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]);
}


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /