Class IoUtil


  • public class IoUtil
    extends Object
    Author:
    Ales Justin
    • Constructor Detail

      • IoUtil

        public IoUtil()
    • Method Detail

      • close

        public static void close​(AutoCloseable closeable)
        Close auto-closeable, unchecked IOException is thrown for any IO exception, IllegalStateException for all others.
        Parameters:
        closeable - the closeable
      • closeIgnore

        public static void closeIgnore​(AutoCloseable closeable)
        Close auto-closeable, ignore any exception.
        Parameters:
        closeable - the closeable
      • toBytes

        public static byte[] toBytes​(InputStream stream)
        Get byte array from stream. Stream is closed at the end.
        Parameters:
        stream - the stream
        Returns:
        stream as a byte array
      • toBytes

        public static byte[] toBytes​(InputStream stream,
                                     boolean closeStream)
        Get byte array from stream.
        Parameters:
        stream - the stream
        Returns:
        stream as a byte array
      • toString

        public static String toString​(InputStream stream)
        Get string from stream. Stream is closed at the end.
        Parameters:
        stream - the stream
        Returns:
        stream as a string
      • toString

        public static String toString​(byte[] bytes)
        Get string from byte array.
        Parameters:
        bytes - the bytes
        Returns:
        byte array as a string
      • toBytes

        public static byte[] toBytes​(String string)
        Get byte array from string.
        Parameters:
        string - the string
        Returns:
        string as byte array
      • toStream

        public static InputStream toStream​(String content)
        Get stream from content.
        Parameters:
        content - the content
        Returns:
        content as stream
      • toStream

        public static InputStream toStream​(byte[] content)