---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
Now Tomcat is also a cool application server
---------------------------------------------------------------------------
----- Original Message ----- From: "David Kerber" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, October 13, 2007 4:56 AM
Subject: Copying large files around


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?

What a cool question.... I've never had the need to move such big files but this is what I would do...

First look at this link.... http://forum.java.sun.com/thread.jspa?threadID=226413&messageID=818728

It will give you the basic streaming model.... ie a POST on the browser side starts sucking down the file from the servlet... So in effect you do not have to worry about the whole file been buffered... it will move across the wire in say 4k blocks.

OK... now if you on a LAN... thats cool, but for the internet this is not good enough...

If you have a look at something like the Opera browser's file transfer it does some cool things, like if you shut down the machine, next time you start up again, it will pick up where you stopped it, it doesnt start with the whole 1 gb file again.... In fact if I built a servlet to do this... I would run the Opera browser download against it and stop and start and see it my servlet is to spec...

I think the way to do it is to to modify the code in that link for RANDOM file access... ie the client knows its got 800 MB already and only asks for 800MB onwards.... so how do they do that.

Look at this link..... http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html and look at the byte range header spec..... I would build the servlet to that.

With such large files.... I think the biggest problem to solve is interruptions.... ie give the user the ability to close the client and go home... tomorrow it starts where it left off..... I think file change headers (almost RSS) type stuff comes into this as well, in case the file is modified before it all downloaded, in which case it MUST start again....

Nice question.... I'm surprized I cant find code like this on the web already.... have a good look around.... it must be there.

You could also add compression to it... and I think GZIP is an option in TC already, or you can just compress the blocks as they go... If its a JPG or GIF.... dont bother with compression it already is.... nice little project

Good Luck....


















---------------------------------------------------------------------
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