public final class IOUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
read(File inputFile)
Reads the content of a file into a string.
|
static String |
read(InputStream inputStream)
Reads the content of a byte stream into a string.
|
static String |
read(Reader reader)
Reads the content of a character stream into a string.
|
static void |
write(File outputFile,
String contents)
Writes text content to a file.
|
static void |
write(OutputStream outputStream,
String contents)
Writes text content to a character stream.
|
static void |
write(Writer writer,
String contents)
Writes text content to a byte stream.
|
public static String read(File inputFile) throws IOException
inputFile - File to read from. Cannot be null.IOException - Thrown when the file cannot be found, or there are I/O errors
reading from the file.public static String read(InputStream inputStream) throws IOException
inputStream - Byte stream to read from. Cannot be null.IOException - Thrown when there are I/O errors reading from the byte stream.public static String read(Reader reader) throws IOException
reader - Character stream to read from. Cannot be null.IOException - Thrown when there are I/O errors reading from the character
stream.public static void write(File outputFile, String contents) throws IOException
outputFile - File to write to. Cannot be null.contents - Text content to write to the file. Cannot be null nor a blank
string.IOException - Thrown when there are I/O errors writing to the file.public static void write(OutputStream outputStream, String contents) throws IOException
outputStream - Character stream to write to. Cannot be null.contents - Text content to write to the character stream. Cannot be null nor
a blank string.IOException - Thrown when there are I/O errors writing to the character stream.public static void write(Writer writer, String contents) throws IOException
writer - Byte stream to write to. Cannot be null.contents - Text content to write to the byte stream. Cannot be null nor
a blank string.IOException - Thrown when there are I/O errors writing to the byte stream.Copyright © 2021. All rights reserved.