Class StreamWorker
java.lang.Object
net.sourceforge.jbizmo.commons.stream.StreamWorker
Utility class to provide common operations upon streams that are used for the communication between client and server
Copyright 2010 (C) by Martin Ganserer
- Version:
- 1.0.0
- Author:
- Martin Ganserer
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStreamWorker(String secret) ConstructorStreamWorker(String secret, int bufferSize) Constructor to define the size of the internal buffer -
Method Summary
Modifier and TypeMethodDescriptionreadObjectFromStream(InputStream in, boolean decrypt) Read a serialized object from an input streamvoidwriteObjectToStream(Serializable object, OutputStream out, boolean encrypt) Write an object to an output streamvoidwriteToOutput(InputStream in, OutputStream out, boolean encryptOutput, boolean decryptInput) Write data from an input stream to an output stream
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
StreamWorker
Constructor- Parameters:
secret-
-
StreamWorker
Constructor to define the size of the internal buffer- Parameters:
secret-bufferSize-
-
-
Method Details
-
writeToOutput
public void writeToOutput(InputStream in, OutputStream out, boolean encryptOutput, boolean decryptInput) throws Exception Write data from an input stream to an output stream- Parameters:
in-out-encryptOutput-decryptInput-- Throws:
Exception- if the stream operation has failed
-
readObjectFromStream
Read a serialized object from an input stream- Parameters:
in-decrypt-- Returns:
- the object
- Throws:
Exception- if the object could not be created from the provided input stream
-
writeObjectToStream
public void writeObjectToStream(Serializable object, OutputStream out, boolean encrypt) throws Exception Write an object to an output stream- Parameters:
object-out-encrypt-- Throws:
Exception- if the object could not be serialized
-