Module org.jcommon

Class IOStreamUtil

    • Constructor Detail

      • IOStreamUtil

        public IOStreamUtil()
    • Method Detail

      • 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,
                                                                   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