org.jfree.io

Class IOUtils

public class IOUtils extends Object

The IOUtils provide some IO related helper methods.

Author: Thomas Morgner.

Method Summary
voidcopyStreams(InputStream in, OutputStream out)
Copies the InputStream into the OutputStream, until the end of the stream has been reached.
voidcopyStreams(InputStream in, OutputStream out, int buffersize)
Copies the InputStream into the OutputStream, until the end of the stream has been reached.
voidcopyWriter(Reader in, Writer out)
Copies the contents of the Reader into the Writer, until the end of the stream has been reached.
voidcopyWriter(Reader in, Writer out, int buffersize)
Copies the contents of the Reader into the Writer, until the end of the stream has been reached.
StringcreateRelativeURL(URL url, URL baseURL)
Creates a relative url by stripping the common parts of the the url.
StringgetFileExtension(String file)
Returns the file extension of the given file name.
StringgetFileName(URL url)
Extracts the file name from the URL.
static IOUtilsgetInstance()
Gets the singleton instance of the utility package.
booleanisSubDirectory(File base, File child)
Checks, whether the child directory is a subdirectory of the base directory.
StringstripFileExtension(String file)
Removes the file extension from the given file name.

Method Detail

copyStreams

public void copyStreams(InputStream in, OutputStream out)
Copies the InputStream into the OutputStream, until the end of the stream has been reached. This method uses a buffer of 4096 kbyte.

Parameters: in the inputstream from which to read. out the outputstream where the data is written to.

Throws: IOException if a IOError occurs.

copyStreams

public void copyStreams(InputStream in, OutputStream out, int buffersize)
Copies the InputStream into the OutputStream, until the end of the stream has been reached.

Parameters: in the inputstream from which to read. out the outputstream where the data is written to. buffersize the buffer size.

Throws: IOException if a IOError occurs.

copyWriter

public void copyWriter(Reader in, Writer out)
Copies the contents of the Reader into the Writer, until the end of the stream has been reached. This method uses a buffer of 4096 kbyte.

Parameters: in the reader from which to read. out the writer where the data is written to.

Throws: IOException if a IOError occurs.

copyWriter

public void copyWriter(Reader in, Writer out, int buffersize)
Copies the contents of the Reader into the Writer, until the end of the stream has been reached.

Parameters: in the reader from which to read. out the writer where the data is written to. buffersize the buffer size.

Throws: IOException if a IOError occurs.

createRelativeURL

public String createRelativeURL(URL url, URL baseURL)
Creates a relative url by stripping the common parts of the the url.

Parameters: url the to be stripped url baseURL the base url, to which the url is relative to.

Returns: the relative url, or the url unchanged, if there is no relation beween both URLs.

getFileExtension

public String getFileExtension(String file)
Returns the file extension of the given file name. The returned value will contain the dot.

Parameters: file the file name.

Returns: the file extension.

getFileName

public String getFileName(URL url)
Extracts the file name from the URL.

Parameters: url the url.

Returns: the extracted filename.

getInstance

public static IOUtils getInstance()
Gets the singleton instance of the utility package.

Returns: the singleton instance.

isSubDirectory

public boolean isSubDirectory(File base, File child)
Checks, whether the child directory is a subdirectory of the base directory.

Parameters: base the base directory. child the suspected child directory.

Returns: true, if the child is a subdirectory of the base directory.

Throws: IOException if an IOError occured during the test.

stripFileExtension

public String stripFileExtension(String file)
Removes the file extension from the given file name.

Parameters: file the file name.

Returns: the file name without the file extension.