net.sf.jlayercheck.util.io
Class IOHelper

java.lang.Object
  extended by net.sf.jlayercheck.util.io.IOHelper

public class IOHelper
extends Object

Some helper methods for file and io handling.

Version:
$Id: IOHelper.java 18 2007-05-08 21:49:53Z stuelten $
Author:
timo, $Author: stuelten $

Field Summary
static int BUFFER_SIZE
          Buffer size for IO.
 
Constructor Summary
IOHelper()
           
 
Method Summary
static void close(InputStream stream)
          Close stream, catching all exceptions.
static void close(OutputStream stream)
          Close stream, catching all exceptions.
static void close(Reader reader)
          Close reader, catching all exceptions.
static void close(Writer writer)
          Close writer, catching all exceptions.
static void copy(File from, File to)
          Copy file to another file
static void copy(InputStream in, OutputStream out)
          Copy content from in to out.
static void copy(Reader in, Writer out)
          Copy content from in to out.
static void copy(URL from, File to)
          Copy content from URL to a file
static String readContent(URL url)
          Read content from URL into string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
Buffer size for IO. 2KB for most systems.

See Also:
Constant Field Values
Constructor Detail

IOHelper

public IOHelper()
Method Detail

close

public static void close(OutputStream stream)
Close stream, catching all exceptions.

Parameters:
stream -

close

public static void close(InputStream stream)
Close stream, catching all exceptions.

Parameters:
stream -

close

public static void close(Reader reader)
Close reader, catching all exceptions.

Parameters:
reader -

close

public static void close(Writer writer)
Close writer, catching all exceptions.

Parameters:
writer -

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Copy content from in to out.

Parameters:
in - The stream to read from
out - The stream to write to
Throws:
IOException

copy

public static void copy(Reader in,
                        Writer out)
                 throws IOException
Copy content from in to out.

Parameters:
in - The reader to read from
out - The writer to write to
Throws:
IOException

copy

public static void copy(File from,
                        File to)
Copy file to another file

Parameters:
from - source file
to - destination file

copy

public static void copy(URL from,
                        File to)
Copy content from URL to a file

Parameters:
from - source
to - destination file

readContent

public static String readContent(URL url)
Read content from URL into string.

Parameters:
url - URL to read
Returns:
a String containing complete content


Copyright © 2007. All Rights Reserved.