Name: dbT83986 Date: 02/09/99
/*
Using JDK-1.1.7A or B
The java.io.File class' list() method does not properly return
filenames which contain the Euro currency symbol (for Euro
enabled english locales - ISO8859-15).
Since our code is multi-platform (Win32,Solaris,AIX,HPUX) we
cannot use JDK 1.2 yet. It is critically important to us that
this bug is fixed in a patch to JDK-1.1.7 or in JDK-1.1.8.
The following program creates a file in the current directory
whose name contains the euro currency symbol (using
FileOutputStream). Then the File class is used to list the
contents of the current directory. The euro currency symbol is
incorrectly mapped to a question mark (the character encoding
fails to preserve the euro symbol).
After running, the file with the euro currency symbol is
properly created (as reported by the os), but the directory
listing from the above code replaces the euro symbol with
a question mark.
*/
import java.io.*;
import java.util.*;
public class EuroTest {
public static void main(String argv[]) {
try {
// Create a file with the euro currency symbol.
FileOutputStream ostream = new FileOutputStream("Euro_\u20ac");
ostream.write((int) 'A'); // Write a byte to the file
ostream.close();
// Now use File to list the current directory
File curdir = new File(".");
String[] dirlist = curdir.list();
for (int i = 0; i < dirlist.length; i++)
System.out.println(dirlist[i]);
}
catch(Throwable t) {
t.printStackTrace();
}
}
}
(Review ID: 53969)
======================================================================