-
Bug
-
Resolution: Duplicate
-
P1
-
None
-
1.1
-
sparc
-
solaris_2.4
Follows is the test program that demonstrates problem. Check
directory for file "FileName.new". Instead you find file "Filename.tmp"
that means that rename failed. Also notice that you will see
"Operation Successfull = : true" i.e. method renameTo() returned true.
While no file is renamed.
--------------8<----- TestFileRename.java ------------------------import java.io.*;
public class TestFileRename {
public static void main(String[] argv) {
try {
File tmpFile = new File("Filename.tmp");
FileOutputStream fout = new FileOutputStream(tmpFile);
System.getProperties().save(fout, "TmpFile Testing Rename");
fout.close();
// Create Dest file
File dest = new File("FileName.new");
System.out.println("Operation Successfull = : " + tmpFile.renameTo(dest));
if (dest.exists())
System.out.println("File Renamed to:" + dest.toString());
else
System.out.println("Rename Filed");
}
catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
directory for file "FileName.new". Instead you find file "Filename.tmp"
that means that rename failed. Also notice that you will see
"Operation Successfull = : true" i.e. method renameTo() returned true.
While no file is renamed.
--------------8<----- TestFileRename.java ------------------------import java.io.*;
public class TestFileRename {
public static void main(String[] argv) {
try {
File tmpFile = new File("Filename.tmp");
FileOutputStream fout = new FileOutputStream(tmpFile);
System.getProperties().save(fout, "TmpFile Testing Rename");
fout.close();
// Create Dest file
File dest = new File("FileName.new");
System.out.println("Operation Successfull = : " + tmpFile.renameTo(dest));
if (dest.exists())
System.out.println("File Renamed to:" + dest.toString());
else
System.out.println("Rename Filed");
}
catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
- duplicates
-
JDK-4014643 java.io.File.RenameTo is broken
- Closed