Class StreamWorker

java.lang.Object
net.sourceforge.jbizmo.commons.stream.StreamWorker

public class StreamWorker extends Object

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 Details

  • Constructor Details

    • StreamWorker

      public StreamWorker(String secret)
      Constructor
      Parameters:
      secret -
    • StreamWorker

      public StreamWorker(String secret, int bufferSize)
      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

      public Object readObjectFromStream(InputStream in, boolean decrypt) throws Exception
      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