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

The JFileChooser sees a binary file format as a directory

XMLWordPrintable



      Name: jk109818 Date: 01/22/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      The JFileChooser sees a binary file format as a directory.
      It is displayed as a directory, and double-clicking on it
      tries to bring you into that directory. The files are in a
      propriatary binary file format.
      This happens in our application as well as Forte, so I am
      confident that the chooser is reading the file header and
      mistaking it for a directory.

      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.You would need an example of the file that causes the
      problem.
      2.Use the chooser to enter a directory containing the
      files. They show up with their trailer, such as akran.cdf,
      but they have a directory icon rather than file icon.
      3.Double click on the file. The dialog indicates you are
      in that 'directry' and the directory is empty. You can
      navigate out.
      4.Sincle click the file and it enters the "File name" box,
      or type the name into the "File name" box and click on Open
      and the file is read into the program as normal.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expect to see the file listed as a file.
      Actual get the file showing up and behaving as a directory.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No errors are displyed, no stack trace is generated.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      You would need an example file from which to work as it is not a coding
      problem. Contact me for a file, or make one yourself. To create a file
      yourself, the following should produce the problem. I have only done it with
      full files using real data:
      Make a test file where the first line is
      <GENERAL>

      The file should be at least 100k. gzip the file then xor the first 20
      characters with char ENCRYPTION_XOR_CHARACTER = 111
          static final int ENCRYPTION_BUFFER_SIZE = 20;
          
          static final char ENCRYPTION_XOR_CHARACTER = 111;
          public void encryptFileHeader(String cdfFileName,String tempFile){
              //open this text file and zip into binary format. then encrypt first 20
      chars
              DarwinStatusPane.updateText("Encrypting the CDF file");
              File cdfFile = null;
              try{
                  File textFile = new File(cdfFileName);
                  BufferedInputStream in = new BufferedInputStream(new FileInputStream
      (textFile),1000000);
                  
                  String fileName = tempFile + ".cdf";
                  cdfFile = new File(fileName);
                  FileOutputStream fos = new FileOutputStream(cdfFile);
                  GZIPOutputStream zipOut = new GZIPOutputStream(fos,1000000);
                  int available = in.available();
                  int byteValue = in.read();
                  while(byteValue != -1){
                      zipOut.write(byteValue);
                      byteValue = in.read();
                  }
                  //System.out.println("there are " + available + "bytes in input
      file");
                  zipOut.flush(); zipOut.close();
                  fos.flush();fos.close();
              }catch(IOException e){
                  System.out.println("ExportCDF :readFile. IO Error = "+e);
                  e.printStackTrace();
              }catch (Exception e) {
                  System.out.println("Error in file creation in ExportCDF"+
      e.getMessage());
              }
              // now encript the cdf file
              cdfFileName = cdfFile.getAbsolutePath();
              RandomAccessFile encryptedFile = null;
              try {
                  encryptedFile = new RandomAccessFile(cdfFileName, "rw");
                  // Read in header
                  byte[] cBuffer = new byte[ENCRYPTION_BUFFER_SIZE];
                  encryptedFile.seek(0);
                  int nCount = encryptedFile.read(cBuffer, 0,
      ENCRYPTION_BUFFER_SIZE);
                  if (nCount != ENCRYPTION_BUFFER_SIZE) {
                      throw new IOException("Read error in file " + cdfFileName);
                  }
                  
                  // XOR bytes
                  for (int index = 0; index < ENCRYPTION_BUFFER_SIZE; ++index) {
                      cBuffer[index] ^= ENCRYPTION_XOR_CHARACTER;
                  }
                  
                  // Write out header
                  encryptedFile.seek(0);
                  encryptedFile.write(cBuffer, 0, ENCRYPTION_BUFFER_SIZE);
              }catch(IOException e){
                  System.out.println("LoadCDF.encryptFileHeader. IO Error = "+e);
                  //e.printStackTrace();
              }catch(Exception e1){
                  System.out.println("Exception in encryptFileHeader = "+e1);
                  //e1.printStackTrace();
              }
              
              try {
                  encryptedFile.close();
              }catch(Exception e){ }
          }

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      In the user interface, don't double-click on the file,
      single click and click on Open.
      (Review ID: 178862)
      ======================================================================

            Unassigned Unassigned
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: