Class StreamUtil

java.lang.Object
net.targetr.wtm3.io.StreamUtil

public class StreamUtil extends Object
Useful utilities for working with streams.
Author:
Dr Michael Gardiner
  • Field Details

    • MAX_DATA_LENGTH

      public static final int MAX_DATA_LENGTH
      The maximum number of bytes to read before automatically aborting.
      See Also:
  • Constructor Details

    • StreamUtil

      public StreamUtil()
  • Method Details

    • readFully

      public static byte[] readFully(InputStream in) throws IOException
      Reads until end of stream into a byte array.
      Parameters:
      in - stream to read.
      Returns:
      filled byte array.
      Throws:
      IOException - An exception occurred while reading.
    • readFully

      public static byte[] readFully(InputStream in, int limit) throws IOException
      Reads until end of stream or limit into a byte array.
      Parameters:
      in - stream to read.
      limit - maximum number of bytes to read.
      Returns:
      filled byte array.
      Throws:
      IOException - An exception occurred while reading.