|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.sdsc.sirius.io.FileTransfer
copy or download a file.
Constructor Summary | |
FileTransfer()
constructor |
|
FileTransfer(int buffSize)
constructor |
Method Summary | |
boolean |
copy(java.io.File source,
java.io.File target)
Copy a file. |
boolean |
copy(java.io.InputStream source,
java.io.OutputStream target)
Copy an InputStream to an OutputStream, until EOF. |
boolean |
copy(java.io.InputStream source,
java.io.OutputStream target,
long length)
Copy an InputStream to an OutputStream. |
boolean |
download(java.net.URL source,
java.io.File target)
Copy a file from a remote URL to a local file on hard disk. |
static void |
main(java.lang.String[] args)
Test driver |
int |
readBlocking(java.io.InputStream in,
byte[] b,
int off,
int len)
Reads exactly len bytes from the input stream
into the byte array. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileTransfer(int buffSize)
buffSize
- how big the i/o chunks are to copy files.public FileTransfer()
Method Detail |
public boolean copy(java.io.File source, java.io.File target)
source
- file to copy on local hard disk.target
- new file to be created on local hard disk.
public boolean download(java.net.URL source, java.io.File target)
source
- remote URL to copy. e.g.
new URL("http://www.billabong.com:80/songs/lyrics.txt")target
- new file to be created on local hard disk.
public boolean copy(java.io.InputStream source, java.io.OutputStream target, long length)
source
- InputStream, left open.target
- OutputStream, left open.length
- how many bytes to copy.
public boolean copy(java.io.InputStream source, java.io.OutputStream target)
source
- InputStream, left open.target
- OutputStream, left open.
public final int readBlocking(java.io.InputStream in, byte[] b, int off, int len) throws java.io.IOException
len
bytes from the input stream
into the byte array. This method reads repeatedly from the
underlying stream until all the bytes are read.
InputStream.read is often documented to block like this, but in
actuality it
does not always do so, and returns early with just a few bytes.
readBlockiyng blocks until all the bytes are read,
the end of the stream is detected,
or an exception is thrown. You will always get as many bytes as
you
asked for unless you get an eof or other exception.
Unlike readFully, you find out how many bytes you did get.
b
- the buffer into which the data is read.off
- the start offset of the data.len
- the number of bytes to read.
java.io.IOException
- if an I/O error occurs.public static void main(java.lang.String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |