Class StreamUtil


  • public class StreamUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.io.InputStream ios)
      exception catching null safe close
      static void close​(java.io.OutputStream ios)
      exception catching null safe close
      static void copy​(java.io.InputStream is, java.io.OutputStream os)
      exception catching null safe copy
      static java.io.InputStream getBufferedInputStream​(java.io.InputStream is)
      return a reasonably well performing stream for is
      static java.io.OutputStream getBufferedOutputStream​(java.io.OutputStream os)
      return a reasonably well performing stream for os
      static VString getLines​(java.io.InputStream in)
      read and tokenize a stream by cr/lf
      static byte[] getMD5​(java.io.InputStream is)
      calculate the md5 hash
      static boolean replaceBytes​(java.io.InputStream in, java.io.OutputStream out, byte[] srcbytes, byte[] targetbytes, int nReplace)
      replace all occurences of srcbytes with targetbytes
      static void reset​(java.io.InputStream stream)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StreamUtil

        public StreamUtil()
    • Method Detail

      • getBufferedInputStream

        public static java.io.InputStream getBufferedInputStream​(java.io.InputStream is)
        return a reasonably well performing stream for is
        Parameters:
        is -
        Returns:
        the buffered stream
      • getBufferedOutputStream

        public static java.io.OutputStream getBufferedOutputStream​(java.io.OutputStream os)
        return a reasonably well performing stream for os
        Parameters:
        os -
        Returns:
        the buffered stream
      • getLines

        public static VString getLines​(java.io.InputStream in)
        read and tokenize a stream by cr/lf
        Parameters:
        in - the input stream to read
        Returns:
        a vector of strings, one for each line
      • replaceBytes

        public static boolean replaceBytes​(java.io.InputStream in,
                                           java.io.OutputStream out,
                                           byte[] srcbytes,
                                           byte[] targetbytes,
                                           int nReplace)
        replace all occurences of srcbytes with targetbytes
        Parameters:
        in -
        out -
        srcbytes -
        targetbytes -
        n -
      • getMD5

        public static byte[] getMD5​(java.io.InputStream is)
        calculate the md5 hash
        Parameters:
        is -
        Returns:
      • close

        public static void close​(java.io.OutputStream ios)
        exception catching null safe close
        Parameters:
        ios -
      • copy

        public static void copy​(java.io.InputStream is,
                                java.io.OutputStream os)
        exception catching null safe copy
        Parameters:
        ios -
      • reset

        public static void reset​(java.io.InputStream stream)
        Parameters:
        stream -
      • close

        public static void close​(java.io.InputStream ios)
        exception catching null safe close
        Parameters:
        ios -