Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4210261

java.io.File list method does not support Euro currency symbol

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.1.7
    • core-libs
    • generic
    • generic



      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)
      ======================================================================

            kkladkosunw Konstantin Kladko (Inactive)
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: