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

Windows NT filename text encoding doesn't handle illegal chars

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.1.8
    • core-libs

      Name: krT82822 Date: 05/03/99


      Background:

      If Windows NT's file system encounters a file with illegal characters (eg, \ / etc) it converts the illegal chars to 0xF0xx. . .

          [reflects correction vs. original, based on later user comment: "I said the characters are 0xFFxx, but they're actually 0xF0xx."]

      Files with illegal characters can be generated on the Mac.

      Somewhere in the Java encoding, these special characters get converted to '?' (0x3F). This makes it impossible to open the file with an
      InputStream or Reader object...

      Code:

      This application just uses a FileDialog to select a file. It then tries to open it with a FileReader which will fail with a FileNotFoundException.
      You'll need to create a file with illegal chars yourself.

      import java.awt.*;
      import java.io.*;

      public class TrivialApplication {

              public static void main(String args[])
      {
      Frame f = new Frame();
      f.pack();

      FileDialog d = new FileDialog(f);
      d.setVisible(true);

      String javaPath;
      System.out.println(javaPath = d.getFile());

      try
      {
      FileReader inStream = new FileReader(javaPath);
      inStream.close();
      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
      }
      }

      Sample output:

      [d:\araxidev\javahacks\illegalntchartest]java -version
      java version "1.1.8"

      [d:\araxidev\javahacks\illegalntchartest]java -fullversion
      java full version "JDK1.1.8K"

      [d:\araxidev\javahacks\illegalntchartest]java -classpath d:\araxioem\private\jdk
      1.1.8\lib\classes.zip;AppClasses.jar TrivialApplication
      90??? fromHell.pdf
      java.io.FileNotFoundException: 90??? fromHell.pdf
              at java.io.FileInputStream.<init>(FileInputStream.java:56)
              at java.io.FileReader.<init>(FileReader.java:35)
              at TrivialApplication.main(TrivialApplication.java)
      (Review ID: 57670)
      ======================================================================

            Unassigned Unassigned
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: