org.melati.util
Class IoUtils

Package class diagram package IoUtils
java.lang.Object
  extended by org.melati.util.IoUtils

public final class IoUtils
extends Object

IO utilities.


Method Summary
static void copy(File from, int buf, File to)
          Copy from one file to another.
static void copy(InputStream i, int buf, OutputStream o)
          Copy from an InputStream to an OutputStream.
static void copy(Reader i, int buf, Writer o)
          Copy from a Reader to a Writer.
static byte[] slurp(File f, int estimate)
          Read a file into a byte array.
static byte[] slurp(InputStream i, int estimate)
          Read into a byte array.
static byte[] slurp(InputStream i, int estimate, int limit)
          Read into a byte array.
static char[] slurp(Reader i, int estimate)
          Read from a Reader into a byte array.
static char[] slurp(Reader i, int estimate, int limit)
          Read from a Reader into a byte array.
static byte[] slurp(URL url, int estimate)
          Read an url into a byte array.
static byte[] slurp(URL url, int estimate, int max)
          Read an url into a byte array, with a limit.
static byte[] slurpOutputOf_bytes(String[] command, int estimate, int limit)
          Read the output of a system command into a byte array.
static String slurpOutputOf(String[] command, int estimate, int limit)
          Read the output of a system command into a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

slurp

public static byte[] slurp(InputStream i,
                           int estimate,
                           int limit)
                    throws IOException
Read into a byte array. Not sure this is really optimal.

Parameters:
i - the inputStream
estimate - approximately how big
limit - will not be bigger than
Returns:
a byte array no bigger than limit
Throws:
IOException

slurp

public static byte[] slurp(InputStream i,
                           int estimate)
                    throws IOException
Read into a byte array. Used in bibliomania.

Parameters:
i - the inputStream
estimate - approximately how big
Returns:
a byte array no bigger than Integer.MAX_VALUE
Throws:
IOException

slurp

public static byte[] slurp(URL url,
                           int estimate)
                    throws IOException
Read an url into a byte array. Used in bibliomania.

Parameters:
url - the url to read
estimate - approximately how big
Returns:
a byte array no bigger than Integer.MAX_VALUE
Throws:
IOException

slurp

public static byte[] slurp(URL url,
                           int estimate,
                           int max)
                    throws IOException
Read an url into a byte array, with a limit. Used in bibliomania.

Parameters:
url - the url to read
estimate - approximately how big
max - limit
Returns:
a byte array no bigger than max
Throws:
IOException

slurp

public static byte[] slurp(File f,
                           int estimate)
                    throws IOException
Read a file into a byte array. Used in bibliomania.

Parameters:
f - file to read
estimate - approximately how big
Returns:
a byte array no bigger than Integer.MAX_VALUE
Throws:
IOException

slurp

public static char[] slurp(Reader i,
                           int estimate,
                           int limit)
                    throws IOException
Read from a Reader into a byte array. Not used elsewhere as of 30/11/2006.

Parameters:
i - Reader to read
estimate - approximately how big
limit - max size
Returns:
a byte array no bigger than limit
Throws:
IOException

slurp

public static char[] slurp(Reader i,
                           int estimate)
                    throws IOException
Read from a Reader into a byte array. Used in bibliomania.

Parameters:
i - Reader to read
estimate - approximately how big
Returns:
a byte array no bigger than Integer.MAX_VALUE
Throws:
IOException

slurpOutputOf_bytes

public static byte[] slurpOutputOf_bytes(String[] command,
                                         int estimate,
                                         int limit)
                                  throws IOException
Read the output of a system command into a byte array. Warning: potentially inefficient. Not used elsewhere as of 30/11/2006.

Parameters:
command - the command to run
estimate - approximately how big
limit - max size
Returns:
a byte array no bigger than limit
Throws:
IOException

slurpOutputOf

public static String slurpOutputOf(String[] command,
                                   int estimate,
                                   int limit)
                            throws IOException
Read the output of a system command into a byte array. Warning: potentially inefficient. Not used elsewhere as of 30/11/2006.

Parameters:
command - the command to run
estimate - approximately how big
limit - max size
Returns:
a String no bigger than limit
Throws:
IOException

copy

public static void copy(InputStream i,
                        int buf,
                        OutputStream o)
                 throws IOException
Copy from an InputStream to an OutputStream. Not used elsewhere as of 30/11/2006.

Parameters:
i - the InputStream
buf - the size of buffer to use
o - the OutputStream
Throws:
IOException

copy

public static void copy(Reader i,
                        int buf,
                        Writer o)
                 throws IOException
Copy from a Reader to a Writer. Not used elsewhere as of 30/11/2006.

Parameters:
i - the Reader
buf - the size of buffer to use
o - the Writer
Throws:
IOException

copy

public static void copy(File from,
                        int buf,
                        File to)
                 throws IOException
Copy from one file to another. Used in bibliomania.

Parameters:
from - input file
buf - the size of buffer to use
to - output file
Throws:
IOException


Copyright © 2000-2010 PanEris. All Rights Reserved.