4 Replies Latest reply on Nov 13, 2006 6:14 PM by 807607

    mobing file, file reference not updated

      I have created two directories, dir1 and dir2. In dir1 i created a file called test.txt. I then moved test.txt from dir1 to dir2 using:
      if(testFile.renameTo(new File(dir2,testFile.getName())))
             System.out.println("File sucessfully moved");
           System.out.println("File NOT sucessfully moved");
      and i get the "File sucessfully moved" message. I also look at the file in explorer and it has indeed moved.

      When i then try to read some of the attributes of the file, using the:
      System.out.println("testFile path:"+testFile.getPath());
      System.out.println("testFile name:"+testFile.getName()); 
      They return the old values, ie that testFile is still in dir1.
      I tried introducing a 10 second delay to see it was a update problem, but it is still getting the old value.

      Any ideas?

      Possible relevant info:
      WinXP Pro SP2
      java version "1.5.0_08"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)