You will need the Java Formatter utility, which can be found here: java.util.Formatter
Then you just need to create an object of type Formatter , for example:
private Formatter output;
In this case, output will be the output file you are writing.
Then you must pass the file name to the output object as follows:
output = new Formatter("name.of.your.file.txt")
After that, you can either copy the contents of the file to the output file using the output.format , which is similar to the System.out.println or printf commands.
Or use the Scanner utility to enter data into memory, then use output.format to output this data to an output object or file.
This is an example of how to write a record for output:
output.format( "%d %s %s %2f\n" , field1.decimal, field2.string, field3.string, field4.double)
There is little more to it than that, but it certainly surpasses data parsing or the use of many complex third-party plugins.
To read this file, you redirect the Scanner utility to read the file instead of the console:
input = new Scanner(new File( "name.of.your.file.txt")