Class StreamUtils

java.lang.Object
at.gv.egovernment.moaspss.util.StreamUtils

public class StreamUtils extends Object
Utility methods for streams.
  • Constructor Details

    • StreamUtils

      public StreamUtils()
  • Method Details

    • compareStreams

      public static boolean compareStreams(InputStream is1, InputStream is2) throws IOException
      Compare the contents of two InputStreams.
      Parameters:
      is1 - The 1st InputStream to compare.
      is2 - The 2nd InputStream to compare.
      Returns:
      boolean true, if both streams contain the exactly the same content, false otherwise.
      Throws:
      IOException - An error occurred reading one of the streams.
    • readStream

      public static byte[] readStream(InputStream in) throws IOException
      Reads a byte array from a stream.
      Parameters:
      in - The InputStream to read.
      Returns:
      The bytes contained in the given InputStream.
      Throws:
      IOException - on any exception thrown
    • readStream

      public static String readStream(InputStream in, String encoding) throws IOException
      Reads a String from a stream, using given encoding.
      Parameters:
      in - The InputStream to read.
      encoding - The character encoding to use for converting the bytes of the InputStream into a String.
      Returns:
      The content of the given InputStream converted into a String.
      Throws:
      IOException - on any exception thrown
    • getStackTraceAsString

      public static String getStackTraceAsString(Throwable t)
      Gets the stack trace of the Throwable passed in as a string.
      Parameters:
      t - The Throwable.
      Returns:
      a String representing the stack trace of the Throwable.