Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

README.md

configJ

configJ is a Java library for easy to read data serialization. It was written to help in the creation of configuration files.

View the Javadocs here

Usage

configJ consists of two main classes, ConfigFile, and ListFile. ConfigFile stores data in a key: value format while ListFile stores String lists line by line.

ConfigFile

When declaring a new instance of the ConfigFile class the constructor creates a new file if the file does not already exists. Here is some example usage:
ConfigFile file = new ConfigFile("data", "txt");
file.set("key1", "value");
file.set("key2", 53);
file.set("key3", true);
file.save();

Will create or load an already existing file named data.txt and would look like this:

key1: value
key2: 53
key3: true

You can also get data from a file using the get methods. Here is an example:

ConfigFile file = new ConfigFile("data", "txt");
int value = file.getInt("key2");
System.out.println("The returned value is: " + value);

This would output 53.

ListFile

The ListFile class is very simple and writes to a file line by line from a String ArrayList. Here is some example usage:
ListFile file = new ListFile("list", "txt");
List<String> list = new ArrayList<String>();
list.add("This is line number one");
list.add("This is line number two");
file.write(list);

The output of this would look like:

This is line number one
This is line number two

You can also turn a file into a List by using the read method as shown here:

ListFile file = new ListFile("list", "txt");
List<String> list = file.read();
for(String line : list) {
    System.out.println(line);
}

Would print the following in the console:

This is line number one
This is line number two

MapFile

The MapFile class is a simple wrapper class that allows for quick and ledgible Map serilization. The MapFile class is simple and like the ListFile class it only consists of 5 methods. Here is some example usage:
MapFile file = new MapFile("Map", "txt");
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("Key 1", "This is a string value");
map.put("Key 2", 71);
map.put("Key 3", false);
file.write(map);

A file would be created named Map.txt and would look similar to the following.

Key 1: This is a string value
Key 2: 71
Key 3: false

DataUtils

DataUtils is a utility class. It contains static methods used for classic serialization and deserialization. You can use them like this:
Data.serialize("This is a string object", "object", "ser");
System.out.println(Data.deserialize("object", "ser"));

About

A Java library for easy to read data serialization

Resources

Packages

No packages published

Languages