|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.rolandkrueger.roklib.io.StreamUtilities
public final class StreamUtilities
Constructor Summary | |
---|---|
private |
StreamUtilities()
|
Method Summary | |
---|---|
static void |
appendFile(File targetFile,
String text)
Appends the given String to the end of a file. |
static void |
copyFiles(File source,
File destination)
Copies the contents of one file to another. |
static void |
copyReaderToWriter(Reader source,
Writer destination)
Copies the data from the given Reader to the given Writer . |
static void |
copyReaderToWriter(Reader source,
Writer destination,
boolean closeSource,
boolean closeDestination)
Copies the data from the given Reader to the given Writer . |
static void |
copyStreams(InputStream source,
OutputStream destination)
Copies the data from the given InputStream to the given
OutputStream . |
static void |
copyStreams(InputStream source,
OutputStream destination,
boolean closeSource,
boolean closeDestination)
Copies the data from the given InputStream to the given
OutputStream . |
static String |
getFileAsString(File file)
Reads the contents of a file into a String. |
static String |
getReaderAsString(Reader source)
Transforms the contents of the given Reader into a String object. |
static String |
getStreamAsString(InputStream source)
Transforms the contents of the given InputStream into a String
object. |
static String |
getStreamAsString(InputStream source,
Charset charset)
|
static String |
getStreamAsString(InputStream source,
String charsetName)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private StreamUtilities()
Method Detail |
---|
public static void copyReaderToWriter(Reader source, Writer destination) throws IOException
Copies the data from the given Reader
to the given Writer
.
Note that the Reader and Writer classes solely process character data and
not byte data. Copying byte data must be done with
copyStreams(InputStream, OutputStream)
.
Both source reader and destination writer will be closed after the copy process.
source
- a character data sourcedestination
- the target of the copy operation
IOException
- if an error occurs while copyingpublic static void copyReaderToWriter(Reader source, Writer destination, boolean closeSource, boolean closeDestination) throws IOException
Copies the data from the given Reader
to the given Writer
.
Note that the Reader and Writer classes solely process character data and
not byte data. Copying byte data must be done with
copyStreams(InputStream, OutputStream)
. The two
boolean parameters let you define whether you want the source reader and
destination writer to be closed after the operation.
source
- a character data sourcedestination
- the target of the copy operationcloseSource
- source reader will be closed if true
closeDestination
- destination writer will be closed if true
IOException
- if an error occurs while copyingpublic static void copyStreams(InputStream source, OutputStream destination) throws IOException
Copies the data from the given InputStream
to the given
OutputStream
.
Both source and destination stream will be closed after the copy process.
source
- a byte data sourcedestination
- the target of the copy operation
IOException
- if an error occurs while copyingpublic static void copyStreams(InputStream source, OutputStream destination, boolean closeSource, boolean closeDestination) throws IOException
Copies the data from the given InputStream
to the given
OutputStream
. The two boolean parameters let you define whether you
want the source and destination streams to be closed after the operation.
source
- a byte data sourcedestination
- the target of the copy operationcloseSource
- source stream will be closed if true
closeDestination
- destination stream will be closed if true
IOException
- if an error occurs while copyingpublic static void copyFiles(File source, File destination) throws IOException
source
- the source filedestination
- the destination file
IOException
- if an error occurs while copyingpublic static String getStreamAsString(InputStream source) throws IOException
InputStream
into a String
object.
source
- an InputStream
the contents of which shall be transformed
into a String
InputStream
IOException
- if an error occurs during the transformationpublic static String getStreamAsString(InputStream source, Charset charset) throws IOException
IOException
public static String getStreamAsString(InputStream source, String charsetName) throws IOException
IOException
public static String getReaderAsString(Reader source) throws IOException
Reader
into a String object.
source
- an Reader
the contents of which shall be transformed into
a String
Reader
IOException
- if an error occurs during the transformationpublic static String getFileAsString(File file) throws IOException
file
- some file
IOException
- if an error occurs while reading the filepublic static void appendFile(File targetFile, String text) throws IOException
targetFile
- the file to append the data String totext
- some String
IOException
- if an error occurred while appending the data
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |