commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ma...@ops.co.at>
Subject Re: VFS ranged downloads?
Date Mon, 14 Feb 2005 21:04:05 GMT
Marcus Crafter wrote:
> Hope all is going well.
Thanks!
> Was just wondering if it's possible to perform a range requested 
> donwload using commons VFS currently? I checked out the API but didn't 
> see anything that allowed one to specify a start byte and range, etc.
There is a RandomAccessContent which makes it possible to access every 
file in an random manner. Though, it wasnt implemented for FTP (now it is).

FileObject fo = 
VFS.getManager().resolveFile("ftp://your-ftp/large-file.bin");
RandomAccessContent ra = 
fo.getContent().getRandomAccessContent(RandomAccessMode.READ);
ra.seek(20);
ra.readFully(buf);

or

InputStream is = ra.getInputStream();

Well - thats it. Using seek() you could set what ftp calls 
"restartOffset" (REST)

I have to do some tests and will commit it in the next few days.

---
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message