IO utils. A bit of reinventing the wheel but we don't want extra dependencies at this stage and we want to be java.
| Type | Name and description |
|---|---|
static void |
close(java.io.Closeable closeable)Closes the target. |
static void |
createDirectory(java.io.File file) |
static void |
createParentDirectory(java.io.File file) |
static void |
downloadToFile(java.lang.String url, java.io.File file)Downloads resource and saves it to a given file |
static java.lang.String |
readFully(java.io.File input)Reads string from the file |
static java.lang.String |
readFully(java.io.InputStream stream)Reads string from the stream and closes it |
static java.lang.String |
readFullyOrDefault(java.io.File input, java.lang.String defaultValue)Reads string from the file or returns empty text if file doesn't exist or can't open |
static void |
writeFile(java.io.File target, java.lang.String content) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Closes the target. Does nothing when target is null. Is not silent, throws exception on IOException.
closeable - the target, may be nullDownloads resource and saves it to a given file
url - location of resource to downloadfile - destination file (not a directory!) where downloaded content will be stored
(file or its parent directories don't need to exist)Reads string from the file
Reads string from the stream and closes it
Reads string from the file or returns empty text if file doesn't exist or can't open