in reply to Re: Java vs. Perl file I/O benchmarks; valid test?
in thread Java vs. Perl file I/O benchmarks; valid test?

A couple things. I don't see the looping that you're talking about in the java versions. The java version from the original poster provides 2 methods for copying, and both read the whole contents of the file into an array and then write that array out to a new file. So the overall idea *is* the same: read the entire first file into memory, write that memory to a second file.

Also, you do realize that the java "version" is actually 2 different methods? So it's not really as long as it appears. Additionally, condensing the JDK 1.4 version I gave below down to some hideuos anonymous objects it gets pretty short. Not on par with the perl version, but hey, that's one of perl's features.

import java.io.*; import java.nio.*; import java.nio.channels.*; public class X2 { public static void main (String [] args) throws Exception { FileChannel in = new FileInputStream(args[0]).getChannel(); new FileOutputStream(args[1]).getChannel().write(in.map( FileChannel.MapMode.READ_ONLY, 0, in.size())); } }
Cheers,

- danboo