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

File.getXSpace() fails when invoked after creation of new file (win)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      windows_xp

      Description

      getXSpace() will fail in windows when tring to get freespace after creation of new file.

      Please see the following code
      <code>
      import java.io.File;
      import static java.lang.System.out;
      import java.io.RandomAccessFile;
      class FreeSpace{
          public static void main(String[] s){
           File f = new File("Foo.txt");
           f.deleteOnExit();
           System.out.println("Before Creation of the file");
           print(f);
      try{
           RandomAccessFile raf = new RandomAccessFile(f,"rw");
           raf.seek(1024 -1);
           raf.write(112);
           raf.close();
           }catch(Exception e){
           e.printStackTrace();
           }
          
          try{
             Thread.sleep(5000);
           }catch(InterruptedException e){
           e.printStackTrace();
           }
         
          System.out.println("After Creation of the File");
      print(f);
         
         
         
           }
      public static void print(File f){
      out.format("Free Disk space %d %n",(f.getFreeSpace()/1024));
           out.format("Total Space %d %n",(f.getTotalSpace()/1024));
           out.format("Usable Space %d %n",(f.getUsableSpace()/1024));
      }
      }
      </code>
      output of the code whne compiled and run in Windows

      <output>
      Z:\Rajendra>java FreeSpace
      Before Creation of the file
      Free Disk space 0
      Total Space 0
      Usable Space 0
      After Creation of the File
      Free Disk space 0
      Total Space 0
      </output>

      Same thing when run in solaris
      <solaris-output>
      bash-3.00$ /net/sqindia/export/disk14/coresqe/releases/mustang/b256/solaris-sparc/jdk1.6.0/bin/javac FreeSpace.java
      bash-3.00$ /net/sqindia/export/disk14/coresqe/releases/mustang/b256/solaris-sparc/jdk1.6.0/bin/java FreeSpace
      Before Creation of the file
      Free Disk space 0
      Total Space 0
      Usable Space 0
      After Creation of the File
      Free Disk space 16090383
      Total Space 105335375
      Usable Space 13983676
      </solaris-output>

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              iris Iris Clark
              Reporter:
              rgutupalsunw Rajendra Gutupalli (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: