Package org.jorigin.io
Class IOStreamUtil
- java.lang.Object
-
- org.jorigin.io.IOStreamUtil
-
public class IOStreamUtil extends java.lang.ObjectThis class is an helper class designed for the handling of I/O streams. This class provide methods for creating and managing streams from various sources.- Since:
- 1.0.0
- Version:
- "1.0.8" - b201801141330L
- Author:
- Julien Seinturier - COMEX S.A. - contact@jorigin.org - https://github.com/jorigin/jeometry
-
-
Constructor Summary
Constructors Constructor Description IOStreamUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancopy(java.io.InputStream source, java.io.OutputStream destination)Simple copy of an input stream to an output stream.static java.io.BufferedInputStreamgetBufferedInputStream(java.lang.String uri)Get a buffered input stream from theurigiven in parameter.static java.io.BufferedInputStreamgetBufferedInputStream(java.lang.String uri, int bufferSize)Get a buffered input stream from theurigiven in parameter.static java.io.BufferedOutputStreamgetBufferedOutputStream(java.lang.String uri)Get a buffered output stream to theurigiven in parameter.static java.io.BufferedOutputStreamgetBufferedOutputStream(java.lang.String uri, int bufferSize)Get a buffered output stream to theurigiven in parameter.static java.io.InputStreamgetInputStream(java.lang.String uri)Open anInputStreamfrom the resource located by the givenuri.static java.io.OutputStreamgetOutputStream(java.lang.String uri)Get an output stream to theurigiven in parameter.
-
-
-
Method Detail
-
getInputStream
public static java.io.InputStream getInputStream(java.lang.String uri) throws java.io.IOExceptionOpen anInputStreamfrom the resource located by the givenuri. The returned stream can be:
- a
FileInputStreamif the resource is a file on a local system; - a
BufferedInputStreamif the resource is anurlor a location on a remote system;
- Parameters:
uri- the location of the resource- Returns:
- the input stream opened to the resource
- Throws:
java.io.IOException- if an error occurs.
- a
-
getBufferedInputStream
public static java.io.BufferedInputStream getBufferedInputStream(java.lang.String uri) throws java.io.IOExceptionGet a buffered input stream from theurigiven in parameter.- Parameters:
uri- the uri source of the input stream.- Returns:
- a buffered input stream.
- Throws:
java.io.IOException- if the stream cannot be set up.
-
getBufferedInputStream
public static java.io.BufferedInputStream getBufferedInputStream(java.lang.String uri, int bufferSize) throws java.io.IOExceptionGet a buffered input stream from theurigiven in parameter. The input stream buffer size is given by thebufferSizeparameter. If the buffer size is less than 1, the buffered input stream created have a default buffer size.- Parameters:
uri- the uri source of the input stream.bufferSize- the size of the buffer- Returns:
- a buffered input stream.
- Throws:
java.io.IOException- if the stream cannot be set up.
-
getOutputStream
public static java.io.OutputStream getOutputStream(java.lang.String uri) throws java.io.IOExceptionGet an output stream to theurigiven in parameter.- Parameters:
uri- the uri of the resource outputed- Returns:
- an output stream to the resource.
- Throws:
java.io.IOException- if the output stream cannot be set up.
-
getBufferedOutputStream
public static java.io.BufferedOutputStream getBufferedOutputStream(java.lang.String uri) throws java.io.IOExceptionGet a buffered output stream to theurigiven in parameter.- Parameters:
uri- the uri source of the output stream.- Returns:
- a buffered output stream.
- Throws:
java.io.IOException- if the stream cannot be set up.- See Also:
getBufferedOutputStream(String, int)
-
getBufferedOutputStream
public static java.io.BufferedOutputStream getBufferedOutputStream(java.lang.String uri, int bufferSize) throws java.io.IOExceptionGet a buffered output stream to theurigiven in parameter. The output stream buffer size is given by thebufferSizeparameter. If the buffer size is less than 1, the buffered output stream created have a default buffer size.- Parameters:
uri- the uri source of the output stream.bufferSize- the size of the buffer- Returns:
- a buffered output stream.
- Throws:
java.io.IOException- if the stream cannot be set up.
-
copy
public static boolean copy(java.io.InputStream source, java.io.OutputStream destination)Simple copy of an input stream to an output stream.- Parameters:
source- Input stream to the sourcedestination- Output stream to the destination- Returns:
trueif the copy was successfull,falseif not
-
-