Class SpinIoUtil


  • public class SpinIoUtil
    extends org.camunda.commons.utils.IoUtil
    Author:
    Daniel Meyer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.nio.charset.Charset ENCODING_CHARSET  
    • Constructor Summary

      Constructors 
      Constructor Description
      SpinIoUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.Reader classpathResourceAsReader​(java.lang.String fileName)  
      static java.io.InputStream convertOutputStreamToInputStream​(java.io.OutputStream outputStream)
      Converts a OutputStream to an InputStream by coping the data directly.
      static java.lang.String getStringFromInputStream​(java.io.InputStream inputStream)
      Convert an InputStream to a String
      static java.lang.String getStringFromInputStream​(java.io.InputStream inputStream, boolean trim)
      Convert an InputStream to a String
      static java.lang.String getStringFromReader​(java.io.Reader reader)
      Convert an Reader to a String
      static java.lang.String getStringFromReader​(java.io.Reader reader, boolean trim)
      Convert an Reader to a String
      static java.io.Reader stringAsReader​(java.lang.String string)  
      • Methods inherited from class org.camunda.commons.utils.IoUtil

        closeSilently, fileAsByteArray, fileAsStream, fileAsStream, fileAsString, fileAsString, getClasspathFile, getClasspathFile, inputStreamAsByteArray, inputStreamAsString, readerAsString, stringAsInputStream
      • Methods inherited from class java.lang.Object

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

      • ENCODING_CHARSET

        public static final java.nio.charset.Charset ENCODING_CHARSET
    • Constructor Detail

      • SpinIoUtil

        public SpinIoUtil()
    • Method Detail

      • convertOutputStreamToInputStream

        public static java.io.InputStream convertOutputStreamToInputStream​(java.io.OutputStream outputStream)
        Converts a OutputStream to an InputStream by coping the data directly. WARNING: Do not use for large data (>100MB). Only for testing purpose.
        Parameters:
        outputStream - the OutputStream to convert
        Returns:
        the resulting InputStream
      • getStringFromInputStream

        public static java.lang.String getStringFromInputStream​(java.io.InputStream inputStream)
                                                         throws java.io.IOException
        Convert an InputStream to a String
        Parameters:
        inputStream - the InputStream to convert
        Returns:
        the resulting String
        Throws:
        java.io.IOException
      • getStringFromInputStream

        public static java.lang.String getStringFromInputStream​(java.io.InputStream inputStream,
                                                                boolean trim)
                                                         throws java.io.IOException
        Convert an InputStream to a String
        Parameters:
        inputStream - the InputStream to convert
        trim - trigger if whitespaces are trimmed in the output
        Returns:
        the resulting String
        Throws:
        java.io.IOException
      • getStringFromReader

        public static java.lang.String getStringFromReader​(java.io.Reader reader)
                                                    throws java.io.IOException
        Convert an Reader to a String
        Parameters:
        reader - the Reader to convert
        Returns:
        the resulting String
        Throws:
        java.io.IOException
      • getStringFromReader

        public static java.lang.String getStringFromReader​(java.io.Reader reader,
                                                           boolean trim)
                                                    throws java.io.IOException
        Convert an Reader to a String
        Parameters:
        reader - the Reader to convert
        trim - trigger if whitespaces are trimmed in the output
        Returns:
        the resulting String
        Throws:
        java.io.IOException
      • classpathResourceAsReader

        public static java.io.Reader classpathResourceAsReader​(java.lang.String fileName)
      • stringAsReader

        public static java.io.Reader stringAsReader​(java.lang.String string)