railo.commons.io
Class IOUtil

java.lang.Object
  extended by railo.commons.io.IOUtil

public final class IOUtil
extends Object

I/O Util


Constructor Summary
IOUtil()
           
 
Method Summary
static void checkEncoding(String encoding)
          check if given encoding is ok
static void closeEL(Closeable c)
          close Closeable without a Exception
static void closeEL(com.lowagie.text.Document doc)
           
static void closeEL(InputStream is)
          close inputstream without a Exception
static void closeEL(InputStream is, OutputStream os)
          close inputstream without a Exception
static void closeEL(Object obj)
          call close method from any Object with a close method.
static void closeEL(OutputStream os)
          close outputstream without a Exception
static void closeEL(Reader r)
          close Reader without a Exception
static void closeEL(javax.mail.Transport t)
          close Writer without a Exception
static void closeEL(Writer w)
          close Writer without a Exception
static void closeEL(ZipFile zip)
           
 void copy(File in, File out)
          copy content of in file to out File
static void copy(InputStream in, OutputStream out, boolean closeIS, boolean closeOS)
          copy a inputstream to a outputstream
static void copy(InputStream in, OutputStream out, int offset, int length)
           
static void copy(InputStream in, OutputStream out, int offset, int length, int blockSize)
           
static void copy(InputStream in, OutputStream out, long offset, long length)
           
static void copy(InputStream is, Resource out, boolean closeIS)
          copy a input resource to a output resource
static void copy(OutputStream out, InputStream in, boolean closeIS, boolean closeOS)
          copy a inputstream to a outputstream
static void copy(Reader reader, Writer writer, boolean closeReader, boolean closeWriter)
          copy a reader to a writer
static void copy(Resource in, OutputStream os, boolean closeOS)
          copy a input resource to a output resource
static void copy(Resource in, Resource out)
          copy a input resource to a output resource
static void flushEL(OutputStream os)
          flush OutputStream without a Exception
static void flushEL(Writer w)
          flush OutputStream without a Exception
static BufferedReader getBufferedReader(Resource res, String charset)
           
static String getMymeType(byte[] barr, String defaultValue)
          return the mime type of a file, dont check extension
static String getMymeType(File file, String defaultValue)
           
static String getMymeType(InputStream is, String defaultValue)
          return the mime type of a file, dont check extension
static String getMymeType(Resource res, String defaultValue)
          return the mime type of a file, dont check extension
static Reader getReader(InputStream is, String charset)
           
static Reader getReader(Resource res, String charset)
           
static Writer getWriter(File file, String charset)
          returns a Reader for the given File and charset (Automaticly check BOM Files)
static Writer getWriter(File file, String charset, boolean append)
          returns a Reader for the given File and charset (Automaticly check BOM Files)
static Writer getWriter(OutputStream os, String charset)
          returns a Reader for the given InputStream
static Writer getWriter(Resource res, String charset)
           
static Writer getWriter(Resource res, String charset, boolean append)
           
static void merge(InputStream in1, InputStream in2, OutputStream out, boolean closeIS1, boolean closeIS2, boolean closeOS)
          copy a inputstream to a outputstream
static void merge(Resource in1, Resource in2, Resource out)
           
static String read(Reader reader, char[] carr)
           
static String read(Reader reader, int size)
           
static BufferedInputStream toBufferedInputStream(InputStream is)
           
static BufferedOutputStream toBufferedOutputStream(OutputStream os)
           
static BufferedReader toBufferedReader(Reader r)
           
static BufferedWriter toBufferedWriter(Writer w)
           
static byte[] toBytes(File file)
           
static byte[] toBytes(InputStream is)
           
static byte[] toBytes(InputStream is, boolean closeStream)
           
static byte[] toBytes(Resource res)
           
static byte[] toBytesMax(InputStream is, int max)
           
static String toString(byte[] barr, String charset)
           
static String toString(InputStream is, String charset)
          reads string data from a InputStream
static String toString(Reader reader)
          reads String data from a Reader
static String toString(Reader reader, boolean buffered)
          reads String data from a Reader
static String toString(Resource file, String charset)
          reads String data from File
static String[] toStringArray(Reader reader)
           
static void write(File file, String string, String charset, boolean append)
          writes a String to a object
static void write(Resource res, byte[] barr)
           
static void write(Resource res, String string, String charset, boolean append)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtil

public IOUtil()
Method Detail

copy

public static final void copy(InputStream in,
                              OutputStream out,
                              boolean closeIS,
                              boolean closeOS)
                       throws IOException
copy a inputstream to a outputstream

Parameters:
in -
out -
closeIS -
closeOS -
Throws:
IOException

merge

public static final void merge(InputStream in1,
                               InputStream in2,
                               OutputStream out,
                               boolean closeIS1,
                               boolean closeIS2,
                               boolean closeOS)
                        throws IOException
copy a inputstream to a outputstream

Parameters:
in -
out -
closeIS -
closeOS -
Throws:
IOException

copy

public static final void copy(OutputStream out,
                              InputStream in,
                              boolean closeIS,
                              boolean closeOS)
                       throws IOException
copy a inputstream to a outputstream

Parameters:
in -
out -
closeIS -
closeOS -
Throws:
IOException

copy

public static void copy(Resource in,
                        Resource out)
                 throws IOException
copy a input resource to a output resource

Parameters:
in -
out -
Throws:
IOException

merge

public static void merge(Resource in1,
                         Resource in2,
                         Resource out)
                  throws IOException
Throws:
IOException

copy

public static void copy(InputStream is,
                        Resource out,
                        boolean closeIS)
                 throws IOException
copy a input resource to a output resource

Parameters:
in -
out -
Throws:
IOException

copy

public static void copy(Resource in,
                        OutputStream os,
                        boolean closeOS)
                 throws IOException
copy a input resource to a output resource

Parameters:
in -
out -
Throws:
IOException

copy

public static final void copy(InputStream in,
                              OutputStream out,
                              int offset,
                              int length)
                       throws IOException
Throws:
IOException

copy

public static final void copy(InputStream in,
                              OutputStream out,
                              long offset,
                              long length)
                       throws IOException
Throws:
IOException

copy

public static final void copy(InputStream in,
                              OutputStream out,
                              int offset,
                              int length,
                              int blockSize)
                       throws IOException
Throws:
IOException

copy

public static final void copy(Reader reader,
                              Writer writer,
                              boolean closeReader,
                              boolean closeWriter)
                       throws IOException
copy a reader to a writer

Parameters:
reader -
writer -
closeReader -
closeWriter -
Throws:
IOException

copy

public void copy(File in,
                 File out)
          throws IOException
copy content of in file to out File

Parameters:
in - input
out - output
Throws:
IOException

closeEL

public static void closeEL(InputStream is,
                           OutputStream os)
close inputstream without a Exception

Parameters:
is -
os -

closeEL

public static void closeEL(InputStream is)
close inputstream without a Exception

Parameters:
is -

closeEL

public static void closeEL(ZipFile zip)

closeEL

public static void closeEL(OutputStream os)
close outputstream without a Exception

Parameters:
os -

closeEL

public static void closeEL(Reader r)
close Reader without a Exception

Parameters:
r -

closeEL

public static void closeEL(Closeable c)
close Closeable without a Exception

Parameters:
r -

closeEL

public static void closeEL(Writer w)
close Writer without a Exception

Parameters:
w -

closeEL

public static void closeEL(javax.mail.Transport t)
close Writer without a Exception

Parameters:
w -

closeEL

public static void closeEL(com.lowagie.text.Document doc)

closeEL

public static void closeEL(Object obj)
call close method from any Object with a close method.

Parameters:
obj -

getReader

public static Reader getReader(Resource res,
                               String charset)
                        throws IOException
Throws:
IOException

getReader

public static Reader getReader(InputStream is,
                               String charset)
                        throws IOException
Throws:
IOException

toString

public static String toString(InputStream is,
                              String charset)
                       throws IOException
reads string data from a InputStream

Parameters:
is -
charset -
Returns:
string from inputstream
Throws:
IOException

toString

public static String toString(byte[] barr,
                              String charset)
                       throws IOException
Throws:
IOException

toString

public static String toString(Reader reader)
                       throws IOException
reads String data from a Reader

Parameters:
reader -
Returns:
readed string
Throws:
IOException

toString

public static String toString(Reader reader,
                              boolean buffered)
                       throws IOException
reads String data from a Reader

Parameters:
reader -
Returns:
readed string
Throws:
IOException

toString

public static String toString(Resource file,
                              String charset)
                       throws IOException
reads String data from File

Parameters:
file -
charset -
Returns:
readed string
Throws:
IOException

toStringArray

public static String[] toStringArray(Reader reader)
                              throws IOException
Parameters:
reader - Reader to get content from it
Returns:
returns the content of the file as String Array (Line by Line)
Throws:
IOException

write

public static void write(File file,
                         String string,
                         String charset,
                         boolean append)
                  throws IOException
writes a String to a object

Parameters:
file -
string - String to write to file
charset -
append - append to cuuretn data or overwrite existing data
Throws:
IOException

write

public static void write(Resource res,
                         String string,
                         String charset,
                         boolean append)
                  throws IOException
Throws:
IOException

write

public static void write(Resource res,
                         byte[] barr)
                  throws IOException
Throws:
IOException

toBytes

public static byte[] toBytes(File file)
                      throws IOException
Parameters:
file -
Returns:
returns the Content of the file as byte array
Throws:
IOException

toBytes

public static byte[] toBytes(Resource res)
                      throws IOException
Parameters:
res -
Returns:
returns the Content of the file as byte array
Throws:
IOException

toBufferedInputStream

public static BufferedInputStream toBufferedInputStream(InputStream is)

toBufferedOutputStream

public static BufferedOutputStream toBufferedOutputStream(OutputStream os)

toBufferedReader

public static BufferedReader toBufferedReader(Reader r)

getBufferedReader

public static BufferedReader getBufferedReader(Resource res,
                                               String charset)
                                        throws IOException
Throws:
IOException

toBufferedWriter

public static BufferedWriter toBufferedWriter(Writer w)

toBytes

public static byte[] toBytes(InputStream is)
                      throws IOException
Parameters:
is -
Returns:
returns the Content of the file as byte array
Throws:
IOException

toBytes

public static byte[] toBytes(InputStream is,
                             boolean closeStream)
                      throws IOException
Throws:
IOException

toBytesMax

public static byte[] toBytesMax(InputStream is,
                                int max)
                         throws IOException
Throws:
IOException

flushEL

public static void flushEL(OutputStream os)
flush OutputStream without a Exception

Parameters:
os -

flushEL

public static void flushEL(Writer w)
flush OutputStream without a Exception

Parameters:
os -

checkEncoding

public static void checkEncoding(String encoding)
                          throws IOException
check if given encoding is ok

Parameters:
encoding -
Throws:
PageException
IOException

getMymeType

public static String getMymeType(byte[] barr,
                                 String defaultValue)
return the mime type of a file, dont check extension

Parameters:
barr -
defaultValue -
Returns:
mime type of the file

getMymeType

public static String getMymeType(File file,
                                 String defaultValue)

getMymeType

public static String getMymeType(InputStream is,
                                 String defaultValue)
return the mime type of a file, dont check extension

Parameters:
barr -
defaultValue -
Returns:
mime type of the file

getMymeType

public static String getMymeType(Resource res,
                                 String defaultValue)
return the mime type of a file, dont check extension

Parameters:
barr -
defaultValue -
Returns:
mime type of the file

getWriter

public static Writer getWriter(Resource res,
                               String charset)
                        throws IOException
Throws:
IOException

getWriter

public static Writer getWriter(Resource res,
                               String charset,
                               boolean append)
                        throws IOException
Throws:
IOException

getWriter

public static Writer getWriter(File file,
                               String charset)
                        throws IOException
returns a Reader for the given File and charset (Automaticly check BOM Files)

Parameters:
file -
charset -
Returns:
Reader
Throws:
IOException

getWriter

public static Writer getWriter(File file,
                               String charset,
                               boolean append)
                        throws IOException
returns a Reader for the given File and charset (Automaticly check BOM Files)

Parameters:
file -
charset -
Returns:
Reader
Throws:
IOException

getWriter

public static Writer getWriter(OutputStream os,
                               String charset)
                        throws IOException
returns a Reader for the given InputStream

Parameters:
is -
charset -
Returns:
Reader
Throws:
IOException

read

public static String read(Reader reader,
                          int size)
                   throws IOException
Throws:
IOException

read

public static String read(Reader reader,
                          char[] carr)
                   throws IOException
Throws:
IOException


Copyright © 2012 Railo