public class IOUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
IOUtils.SavingConfig
Represents a way to save to a file.
|
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isHostReachable(java.lang.String address,
int timeoutMillis)
Checks whether a host is reachable.
|
static java.lang.String |
readFromFile(java.io.File file)
Reads the content of a
File into a String. |
static java.lang.String |
readSingleLineFromFile(java.io.File file)
Reads the content of a
File into a String. |
public static java.lang.String readFromFile(java.io.File file)
File
into a String.File
are also in the output
String.file
- The File
to read the content of.public static java.lang.String readSingleLineFromFile(java.io.File file)
File
into a String.File
will not be present in
the output String.file
- The File
to read the content of.public static boolean isHostReachable(java.lang.String address, int timeoutMillis)
address
- The host's address to check for. If it starts with a protocol
identifier, it is split at "://" and the second part is used
for checking.timeoutMillis
- The timeout milliseconds after which a connection attempt is
considered as failed.true
when the host is reachable. Returns false
when the host is not reachable within the timeoutMillis
or an Exception occurred.