This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
a bug of java.io.File ?
- From: bbskill <bbkills at tom dot com>
- To: java at gcc dot gnu dot org
- Date: Sun, 21 Aug 2005 21:11:13 +0800
- Subject: 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]);
}