JDK-4863147 : (NT only) File.length() returns incorrect length
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2003-05-13
  • Updated: 2003-05-13
  • Resolved: 2003-05-13
Related Reports
Duplicate :  
Description
###@###.### 2003-05-13

J2SE Version (please include all output from java -version flag):
  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)

  and

  java version "1.4.2-rc"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-rc-b22)
  Java HotSpot(TM) Client VM (build 1.4.2-rc-b22, mixed mode)

Does this problem occur on J2SE 1.3, 1.4 or 1.4.1?  Yes / No (pick one)
  Yes.

Operating System Configuration Information (be specific):
  NT service pack 5(works fine with Win2K)

Hardware Configuration Information (be specific):
  Compaq Deskpro

Bug Description:

  File.length() does not reflect the actual length of the file.

Steps to Reproduce (be specific):

  Compile and run FileLength.java file. On Win2K, it will print 3
  but on WinNT, it will print 0.

Test Program(FileLength.java):

import java.io.*;
public class FileLength {
    public static void main(String[] args) throws Exception {
        File f = new File("tmp.tmp");
        Writer w = new FileWriter(f);
        w.write("abc");
        w.flush();
        System.out.println(f.length());
    }
}