net.sourceforge.cobertura.util

Class IOUtil

public abstract class IOUtil extends Object

Helper class with useful I/O operations.

Author: Grzegorz Lukasik

Method Summary
static InputStreamcloseInputStream(InputStream in)
Closes an input stream.
static OutputStreamcloseOutputStream(OutputStream out)
Closes an output stream.
static voidcopyStream(InputStream in, OutputStream out)
Copies bytes from input stream into the output stream.
static byte[]createByteArrayFromInputStream(InputStream in)
Returns an array that contains values read from the given input stream.
static PrintWritergetPrintWriter(File file)
static voidmoveFile(File sourceFile, File destinationFile)
Moves a file from one location to other.

Method Detail

closeInputStream

public static InputStream closeInputStream(InputStream in)
Closes an input stream.

Parameters: in The stream to close.

Returns: null unless an exception was thrown while closing, else returns the stream

closeOutputStream

public static OutputStream closeOutputStream(OutputStream out)
Closes an output stream.

Parameters: out The stream to close.

Returns: null unless an exception was thrown while closing, else returns the stream.

copyStream

public static void copyStream(InputStream in, OutputStream out)
Copies bytes from input stream into the output stream. Stops when the input stream read method returns -1. Does not close the streams.

Throws: IOException If either passed stream will throw IOException. NullPointerException If either passed stream is null.

createByteArrayFromInputStream

public static byte[] createByteArrayFromInputStream(InputStream in)
Returns an array that contains values read from the given input stream.

Throws: NullPointerException If null stream is passed.

getPrintWriter

public static PrintWriter getPrintWriter(File file)

moveFile

public static void moveFile(File sourceFile, File destinationFile)
Moves a file from one location to other.

Throws: IOException If IO exception occur during moving. NullPointerException If either passed file is null.