|
CodeBeamer 5.4.0.1-RC API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.intland.codebeamer.persistence.util.BinaryStreamDtoHelper
public class BinaryStreamDtoHelper
Helper object (with lots of static methods) to load/create instances of BinaryStreamDto from various sources. This must be separate class from BinaryStreamDto, because it depends on jars like struts, which are not deployed with the remoting API! See also, the other helper class: @see BinaryStreamDtoHelperStruts.
Field Summary | |
---|---|
static int |
CHUNK_SIZE
|
Method Summary | |
---|---|
static long |
copyStream(java.io.InputStream in,
java.io.OutputStream out,
long maxBytes)
Must not use Common.copyStream() here, because this class is also used on remote clients, and the Common class references a lot of server side classes !! Copy data from one stream to an other, up to a maximum number of bytes and close all streams afterwards. |
static BinaryStreamDto |
createEmptyStr()
|
static BinaryStreamDto |
createFromBytes(byte[] bytes2)
Create it from a set of bytes |
static BinaryStreamDto |
createFromFile(java.io.File file,
boolean deleteOnClosed,
org.apache.commons.collections.Closure onDeleteFailed)
Factory method to create from file, which will optionally be deleted after the content is read. |
static BinaryStreamDto |
createFromStream(java.io.InputStream input)
|
static BinaryStreamDto |
createFromStream(java.io.InputStream in,
long length)
|
static BinaryStreamDto |
loadFromFile(java.io.File file)
Load a file's full content as byte array into a new BlobStreamDto. |
static BinaryStreamDto |
loadToMemory(BinaryStreamDto dto)
Loads the internal stream fully into memory. |
static void |
saveToFile(BinaryStreamDto binaryStream,
java.io.File outputFile)
Saves the content of a binary stream to a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CHUNK_SIZE
Method Detail |
---|
public static BinaryStreamDto loadToMemory(BinaryStreamDto dto) throws java.io.IOException
BinaryStreamDto
's with streams can't be sent through Hessian, because InputStream is not serializable.
This methods reads all the bytes from the stream in the BinaryStreamDto
and stores that as byte array in the same BinaryStreamDto
, because byte arrays are
Hessian-compliant.
Still after this call the data can only be accessed through getInputStream() method.
dto
- is the BinaryStreamDto whose InputStream to load into the bytes array
java.io.IOException
- If exception during loadpublic static BinaryStreamDto loadFromFile(java.io.File file) throws java.io.IOException
file
- the file
java.io.IOException
public static BinaryStreamDto createFromStream(java.io.InputStream in, long length)
public static BinaryStreamDto createFromBytes(byte[] bytes2)
bytes2
-
public static BinaryStreamDto createEmptyStr()
public static BinaryStreamDto createFromStream(java.io.InputStream input)
public static BinaryStreamDto createFromFile(java.io.File file, boolean deleteOnClosed, org.apache.commons.collections.Closure onDeleteFailed) throws java.io.IOException
file
- The filedeleteOnClosed
- whether to delete the file after it has been read.onDeleteFailed
- Closure called back when the delete of the file is failed. The closure the AutoClosingInputStream object as parameter.
java.io.IOException
public static void saveToFile(BinaryStreamDto binaryStream, java.io.File outputFile) throws java.io.IOException
java.io.IOException
public static long copyStream(java.io.InputStream in, java.io.OutputStream out, long maxBytes) throws java.io.IOException
in
- The input streamout
- The output stream
java.io.IOException
|
CodeBeamer 5.4.0.1-RC API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |