Class IOUtil

java.lang.Object
com.logicaldoc.util.io.IOUtil

public class IOUtil extends Object
  • Method Details

    • close

      public static void close(Closeable resource)
      Close the given resource.
      Parameters:
      resource - The resource to be closed.
    • getLimitedStream

      public static InputStream getLimitedStream(InputStream input, long limit)
      Creates a new input stream that represents the first part of the original stream.
      Parameters:
      input - Original input stream
      limit - Size of the new stream, expressed in bytes
      Returns:
      the limited input stream
    • write

      public static void write(InputStream input, OutputStream output) throws IOException
      Throws:
      IOException
    • write

      public static void write(InputStream input, File output) throws IOException
      Throws:
      IOException
    • readStream

      public static String readStream(InputStream is) throws IOException
      Throws:
      IOException
    • getBytesOfStream

      public static byte[] getBytesOfStream(InputStream stream) throws IOException
      Throws:
      IOException
    • serialize

      public static String serialize(Serializable object, String charset)
      Serializes an object into XML string
      Parameters:
      object - The object to serialize
      charset - The charset to use for the output, if not provided UTF-8 is used instead
      Returns:
      The serialized string
    • deserialize

      public static Object deserialize(String xml)
      Deserializes an XML serialization to obtain the object
      Parameters:
      xml - The XML content
      Returns:
      The recovered object