Seconding Peter's comments:  It is extremely unlikely that you can beat the 
Windows tools for this sort of thing (been there, done that).  Also, if your 
webapp isn't physically on one or the other boxes (as Peter said, preferably 
the reciever), then you are pretty much guaranteed to lose.

That being said, if you insist on using Java, then use a MappedByteBuffer on 
the source, and either a transferTo or TransferFrom to send it to the to. 
On Windows, this makes an order of magnitude difference for 1GB+ files.


"Peter Crowther" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> From: David Kerber [mailto:[EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





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

Reply via email to