Skip to the content.

Fixedformat4j

Fixedformat4j is an easy to use, small and non-intrusive Java framework for working with flat fixed formatted text files. By annotating your code you can set up the offsets and format for your data when reading and writing to and from flat fixed format files.

Fixedformat4j handles many built-in datatypes: String, Character/char, Long/long, Integer/int, Short/short, Double/double, Float/float, Boolean/boolean, Date, LocalDate, and BigDecimal.

It is also straightforward to write and plug in your own formatters for custom datatypes.

Why should I use Fixedformat4j?

Getting started

Annotate your getter methods and use the FixedFormatManager to load and export your fixed-format text. The Quick Start guide walks you through each step with a full working example.

In short: add @Record to your class, add @Field to each getter with an offset and length, then call manager.load(...) or manager.export(...):

FixedFormatManager manager = new FixedFormatManagerImpl();
String line = "string    001232008-05-29";
BasicRecord record = manager.load(BasicRecord.class, line);
record.setIntegerData(100);
System.out.println(manager.export(record)); // "string    001002008-05-29"

See the Quick Start for the full annotated class and step-by-step explanation, or jump straight to Examples for practical scenarios.


Quick Start Usage Examples Get It FAQ Changelog