Package com.logicaldoc.util.io
Class IOUtil
java.lang.Object
com.logicaldoc.util.io.IOUtil
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidClose the given resource.static Objectdeserialize(String xml) Deserializes an XML serialization to obtain the objectstatic voidDownloads an URL into a local filestatic byte[]getBytesOfStream(InputStream stream) static InputStreamgetLimitedStream(InputStream input, long limit) Creates a new input stream that represents the first part of the original stream.static Stringstatic Stringserialize(Serializable object, String charset) Serializes an object into XML stringstatic voidwrite(InputStream input, File output) static voidwrite(InputStream input, OutputStream output) 
- 
Method Details- 
closeClose the given resource.- Parameters:
- resource- The resource to be closed.
 
- 
getLimitedStreamCreates 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- Throws:
- IOException
 
- 
write- Throws:
- IOException
 
- 
readStream- Throws:
- IOException
 
- 
getBytesOfStream- Throws:
- IOException
 
- 
serializeSerializes 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
 
- 
deserializeDeserializes an XML serialization to obtain the object- Parameters:
- xml- The XML content
- Returns:
- The recovered object
 
- 
downloadpublic static void download(String url, File dest, int timeout, int bufferSize) throws IOException, URISyntaxException Downloads an URL into a local file- Parameters:
- url- The URL to download
- dest- The destination local file
- timeout- A connection timeout in seconds
- bufferSize- The buffer size in bytes
- Throws:
- IOException- I/O error
- URISyntaxException- The URL is invalid
 
 
-