Class ByteArrayDownloadTarget
java.lang.Object
net.sf.basedb.opengrid.filetransfer.AbstractFileTransfer
net.sf.basedb.opengrid.filetransfer.ByteArrayDownloadTarget
- All Implemented Interfaces:
DownloadTarget
public class ByteArrayDownloadTarget extends AbstractFileTransfer implements DownloadTarget
Download target implementation for getting the
remote file as a byte array.
- Since:
- 1.0
- Author:
- nicklas
-
Field Summary
Fields Modifier and Type Field Description private ByteArrayOutputStream
data
private int
limit
-
Constructor Summary
Constructors Constructor Description ByteArrayDownloadTarget(String name)
Create a new byte array download target with "unlimited" size. -
Method Summary
Modifier and Type Method Description byte[]
getData()
Get the downloaded data as a byte array.int
getDownloadedSize()
Get the size of the downloaded data.OutputStream
getOutputStream()
Get an ouput stream for writing the file data to the local resource.String
getString(String charset)
Get the downloaded data as a string.Methods inherited from class net.sf.basedb.opengrid.filetransfer.AbstractFileTransfer
getMetadata, getName, initMetadata
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.basedb.opengrid.filetransfer.DownloadTarget
getMetadata, getName
-
Field Details
-
limit
private final int limit -
data
-
-
Constructor Details
-
ByteArrayDownloadTarget
Create a new byte array download target with "unlimited" size.- Parameters:
name
- The name of the "file"
-
-
Method Details
-
getOutputStream
Description copied from interface:DownloadTarget
Get an ouput stream for writing the file data to the local resource.- Specified by:
getOutputStream
in interfaceDownloadTarget
-
getDownloadedSize
public int getDownloadedSize()Get the size of the downloaded data. -
getData
public byte[] getData()Get the downloaded data as a byte array. Note that a copy is made for each call to this method. If no data has been downloaded null is returned. -
getString
Get the downloaded data as a string. If no data has been downloaded null is returned.
-