To read and write text to and from java objects you will annotate your java object with instructions on where data is located in the string and how to translate the data into meaningful objects.

You will use an instance of the FixedFormatManager to load and export the data to and from string representation.

Fixedformat4j rely on your java object adhere to the following conventions for being able to load and export data:

  1. A class that is to be used in fixedformat4j has to be annotated with the Record annotation.
  2. A property is a pair of a getter and a setter method.
  3. The getter method is annotated with instructions on how to convert to and from string representation.


The Following example defines one string property on a pojo class called BasicRecord

public class BasicUsageRecord {

  private String stringData;

  @Field(offset = 1, length = 35)
  public String getStringData() {
    return stringData;

  public void setStringData(String stringData) {
    this.stringData = stringData;


An instance of a fixedformatmanager does the work of translating annotation instructions and controlling the actual parsing and formatting.

Fixedformat4j comes with an implementation of a FixedFormatManager called FixedFormatManagerImpl.


    FixedFormatManager manager = new FixedFormatManagerImpl();

    //load the string into an object representation
    BasicUsageRecord record = manager.load(BasicUsageRecord.class, "initial string");

    //operate the record in object representation
    record.setStringData("some other string");

    //export back to string representation
    String exportedString = manager.export(record);
    //... do something with the new string


As you can see you will use annotations to instruct the manager on how to load and export data.

A complete list of annotations can be found here .