net.sourceforge.cobertura.util

Class IOUtil


public abstract class IOUtil
extends java.lang.Object

Helper class with useful I/O operations.
Author:
Grzegorz Lukasik

Method Summary

static InputStream
closeInputStream(InputStream in)
Closes an input stream.
static OutputStream
closeOutputStream(OutputStream out)
Closes an output stream.
static void
copyStream(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 void
moveFile(File sourceFile, File destinationFile)
Moves a file from one location to other.

Method Details

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)
            throws IOException
Copies bytes from input stream into the output stream. Stops when the input stream read method returns -1. Does not close the streams.

createByteArrayFromInputStream

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

moveFile

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