public class DiskIO extends Object implements IDataRetriever
| Constructor and Description |
|---|
DiskIO(DiskIO other)
Constructor that copies over settings from another DiskIO.
|
DiskIO(com.google.gson.Gson gson,
Charset charset)
Constructor that sets the GSON (de-)serializer for reading and
writing JSON objects.
|
| Modifier and Type | Method and Description |
|---|---|
org.jsoup.nodes.Document |
getHtml(String filePath)
Tries to parse the content from a specified path as a
HTML document.
|
<T> T |
getObject(File file,
Class<T> targetClass)
Tries to parse the content of a specified file as an object.
|
<T> T |
getObject(File file,
Type targetType)
Tries to parse the content of a specified file as an object.
|
<T> T |
getObject(String filePath,
Class<T> targetClass)
Tries to parse the content from a specified path as a
JSON object.
|
<T> T |
getObject(String filePath,
Type targetType)
Tries to parse the content from a specified path as a
JSON object.
|
String |
getString(File file)
Tries to parse the content of a specified file as a string.
|
String |
getString(String filePath)
Tries to parse the content from a specified path as a string.
|
void |
setCharset(Charset charset)
Changes the charset used for (de-)serializing requests.
|
String |
writeObjectToFile(File file,
Object obj)
Attempts to transform an object to a JSON object and writes it to a file on disk.
|
String |
writeObjectToFile(String filePath,
Object obj)
Attempts to transform an object to a JSON object and writes it to a file on disk.
|
String |
writeStringToFile(File file,
String fileContent)
Writes a string to a file on disk.
|
String |
writeStringToFile(String filePath,
String fileContent)
Writes a string to a file on disk.
|
public DiskIO(com.google.gson.Gson gson,
Charset charset)
gson - the GSON (de-)serializer for reading and writing JSON objectscharset - the charset of the files to be read and writtenpublic String writeStringToFile(String filePath, String fileContent)
filePath - the complete path to the filefileContent - the string that is to be written to the filepublic String writeStringToFile(File file, String fileContent)
file - the file to which the String is writtenfileContent - the string that is to be written to the filepublic String writeObjectToFile(String filePath, Object obj)
filePath - the complete path to the fileobj - the object that is to be written to the filepublic String writeObjectToFile(File file, Object obj)
file - the file to which the object should be writtenobj - the object that is to be written to the filepublic String getString(File file)
file - the file that is to be parsedpublic <T> T getObject(File file, Class<T> targetClass)
T - the type of the object that is to be readfile - a JSON file representing the objecttargetClass - the class of the object that is readpublic <T> T getObject(File file, Type targetType)
T - the type of the object that is to be readfile - a JSON file representing the objecttargetType - the type of the object that is readpublic String getString(String filePath)
IDataRetrievergetString in interface IDataRetrieverfilePath - the path to a HTML filepublic <T> T getObject(String filePath, Class<T> targetClass)
IDataRetrievergetObject in interface IDataRetrieverT - the type of the object that is to be readfilePath - the path to a JSON filetargetClass - the class of the object that is read from discpublic <T> T getObject(String filePath, Type targetType)
IDataRetrievergetObject in interface IDataRetrieverT - the type of the object that is to be readfilePath - the path to a JSON filetargetType - the type of the object that is read from discpublic org.jsoup.nodes.Document getHtml(String filePath)
IDataRetrievergetHtml in interface IDataRetrieverfilePath - the path to a HTML filepublic void setCharset(Charset charset)
IDataRetrieversetCharset in interface IDataRetrievercharset - the new charsetCopyright © 2017–2019. All rights reserved.