Package org.japprove.files
Class JsonFile
java.lang.Object
org.japprove.files.JsonFile
public class JsonFile
extends java.lang.Object
JsonFile is a wrapper around TextFile that provides functionality to read and write data
of JsonFiles.-
Constructor Summary
Constructors Constructor Description JsonFile(java.lang.String path) -
Method Summary
Modifier and Type Method Description voidcreate()Checks if the File already exists and creates a new one if not.booleanexists()Returns true if this file exists.java.lang.StringgetName()Returns the name of the correspondingTextFile.com.fasterxml.jackson.databind.JsonNodereadData()Reads the data of theJsonFileand returns aJsonNode.voidwriteData(com.fasterxml.jackson.databind.JsonNode data)Stores aJsonNodein theJsonFile.
-
Constructor Details
-
JsonFile
public JsonFile(java.lang.String path)
-
-
Method Details
-
writeData
public void writeData(com.fasterxml.jackson.databind.JsonNode data) throws java.io.FileNotFoundException, com.fasterxml.jackson.core.JsonProcessingExceptionStores aJsonNodein theJsonFile.- Parameters:
data- theJsonNodethat should be stored- Throws:
java.io.FileNotFoundException- thrown if the file not existscom.fasterxml.jackson.core.JsonProcessingException- thrown if an error with the json object occurs
-
readData
public com.fasterxml.jackson.databind.JsonNode readData()Reads the data of theJsonFileand returns aJsonNode.- Returns:
- the content of the
JsonFilein aJsonNode
-
create
Checks if the File already exists and creates a new one if not.- Throws:
FileCreationFailedException- thrown if the file cannot be created
-
getName
public java.lang.String getName()Returns the name of the correspondingTextFile.- Returns:
- the name of the corresponding
TextFile.
-
exists
public boolean exists()Returns true if this file exists.- Returns:
- true if this file exists.
-