J2SE Version (please include all output from java -version flag):
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Client: Microsoft Windows XP [Version 5.1.2600]
Bug Description:
Insufficient System Resources When Copying Large Files with NIO FileChannels
This is a duplicate of bug 4938442 which was closed as not a defect.
This has been tested on many systems on completely different Networks and
does not work on any of them.
Just retested using 1.6.0_13 and this problem still exists.
The problem can be reproduced when copying a file > 64 MB to a shared directory.
Example: On Win_XP machine copying jdk-6u13-windows-i586-p.exe as the file (about 74.9 MB) to a remote shared directory on a Linux server.
Test program:
import static java.lang.System.*;
import java.io.*;
import java.nio.channels.*;
public class Test {
public static void main(String args[]) {
File sourceFile = new File("c:/test.exe"); // some local file that is larger than 64 MB
File destinationFile = new File("s:/test.exe"); // where the destination is a shared directory on a remote machine
if (destinationFile.exists()) {
destinationFile.delete();
}
try {
FileInputStream input = new FileInputStream(sourceFile);
try {
FileOutputStream output = new FileOutputStream(destinationFile);
try {
FileChannel inputChannel = input.getChannel();
long size = inputChannel.size();
if (size != inputChannel.transferTo(0, size, output.getChannel())) {
throw new IOException("Incomplete Transfer");
}
}
finally {
output.close();
}
}
finally {
input.close();
}
}
catch (IOException ex) {
out.println(ex);
}
}
}