Class IOStreamUtil

java.lang.Object
org.jorigin.io.IOStreamUtil

public class IOStreamUtil extends Object
This 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.14" - b202111241200L
Author:
Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020 - github.com/jorigin/jcommon (contact@jorigin.org)
  • Constructor Details

    • IOStreamUtil

      public IOStreamUtil()
  • Method Details

    • getInputStream

      public static InputStream getInputStream(String uri) throws IOException
      Open an InputStream from the resource located by the given uri. The returned stream can be:
      Parameters:
      uri - the location of the resource
      Returns:
      the input stream opened to the resource
      Throws:
      IOException - if an error occurs.
    • getBufferedInputStream

      public static BufferedInputStream getBufferedInputStream(String uri) throws IOException
      Get a buffered input stream from the uri given in parameter.
      Parameters:
      uri - the uri source of the input stream.
      Returns:
      a buffered input stream.
      Throws:
      IOException - if the stream cannot be set up.
    • getBufferedInputStream

      public static BufferedInputStream getBufferedInputStream(String uri, int bufferSize) throws IOException
      Get a buffered input stream from the uri given in parameter. The input stream buffer size is given by the bufferSize parameter. 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:
      IOException - if the stream cannot be set up.
    • getOutputStream

      public static OutputStream getOutputStream(String uri) throws IOException
      Get an output stream to the uri given in parameter.
      Parameters:
      uri - the uri of the resource outputed
      Returns:
      an output stream to the resource.
      Throws:
      IOException - if the output stream cannot be set up.
    • getBufferedOutputStream

      public static BufferedOutputStream getBufferedOutputStream(String uri) throws IOException
      Get a buffered output stream to the uri given in parameter.
      Parameters:
      uri - the uri source of the output stream.
      Returns:
      a buffered output stream.
      Throws:
      IOException - if the stream cannot be set up.
      See Also:
    • getBufferedOutputStream

      public static BufferedOutputStream getBufferedOutputStream(String uri, int bufferSize) throws IOException
      Get a buffered output stream to the uri given in parameter. The output stream buffer size is given by the bufferSize parameter. 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:
      IOException - if the stream cannot be set up.
    • copy

      public static boolean copy(InputStream source, OutputStream destination)
      Simple copy of an input stream to an output stream.
      Parameters:
      source - Input stream to the source
      destination - Output stream to the destination
      Returns:
      true if the copy was successfull, false if not