tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Crowther" <Peter.Crowt...@melandra.com>
Subject RE: Copying large files around
Date Sat, 13 Oct 2007 22:45:25 GMT
> From: David Kerber [mailto:dckerber@verizon.net] 
> What is the most efficient (=fastest) way of copying large (> 
> 1GB [yes, 
> that's a Giga]) files around the network in java when running under 
> tomcat 5.5.x?  Do I use a FileInputStream and FileOutputStream with a 
> large byte[] array?  Or what?

If you *definitely* want efficient, and you're on Windows, then:

- Do not use Java, use OS-level tools;
- Run the tools on the receiving machine, not the sending machine.

You don't have to worry about differences in buffer sizes between the
network and whatever chunking you're using on the Java file copy, and
I'm pretty sure I've seen "copy" pre-allocate the entire file space when
the target file is local (because it knows it's copying a source file
and it knows it has exclusive access, so the size doesn't change).  I've
never seen that behaviour when "copy" is running to a network share.

The easiest way of doing this on Windows is via the AT command: write
yourself an at that runs a couple of minutes in the future (use Java to
look up the time :-) ), similar to:

at \\targetserver 21:02 "c:\jobs\copyFromLive.bat"

Ugly as sin, but it works and it's fast.

		- Peter

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message