File.renameTo() doesn't behave the same way on Win32 and Solaris.
The following simple test shows the problem.
import java.io.*;
public class test {
public static void main(String argv[]) throws IOException {
File tmpFile = File.createTempFile("tmp");
System.out.println(tmpFile);
File inputFile = new File("junk");
System.out.println(inputFile);
// another bug here, see 4017593
// win32 needs a delete() before rename
inputFile.delete();
System.out.println(tmpFile.renameTo(inputFile));
}
}
On Solaris, if property java.io.tmpdir is set to another mounted
filesystem other than the current one , or the user specifies
that explicitly when creating the tmpFile, the renameTo() call
will fail.
On Win32, the test works as expected.
The following simple test shows the problem.
import java.io.*;
public class test {
public static void main(String argv[]) throws IOException {
File tmpFile = File.createTempFile("tmp");
System.out.println(tmpFile);
File inputFile = new File("junk");
System.out.println(inputFile);
// another bug here, see 4017593
// win32 needs a delete() before rename
inputFile.delete();
System.out.println(tmpFile.renameTo(inputFile));
}
}
On Solaris, if property java.io.tmpdir is set to another mounted
filesystem other than the current one , or the user specifies
that explicitly when creating the tmpFile, the renameTo() call
will fail.
On Win32, the test works as expected.
- duplicates
-
JDK-4073756 java.io.File.renameTo fails on a NFS mounted location
-
- Closed
-
- relates to
-
JDK-4017593 java.io.File.renameTo has different semantics on Solaris and Win32
-
- Closed
-