FixedFormat4jFrom Libzter
fixedformat4j
[edit] OverviewFixedformat4j is a simple library specialized in reading fixed format flat text files. This is stil a common format in legacy systems/mainframes.
[edit] SpecificationsFixedformat4j depends on the Apache java libraries commons-lang and commons-logging. [edit] Features
[edit] InstallationYou will have to copy the jar file and make sure it is included in you classpath. You will also have to make sure commons-lang and commons-logging are installed (or in your java classpath). [edit] UsageThis is a sample of a flat fixed format data file 568 Say Hello to my little friend 1456 John. D. Smith 4242424 Some text This code defines a Record (line) and how it is formated public class MyRecord{ private int myInt; private String myString; @Field(offset=1,length=9,align=Align.RIGHT) public int getInt(){ return myInt;} public void setInt(int num){myInt=num;} @Field(offset=12,length=30) public String getStr(){ return myString;} public void setStr(String str){myString=str;} } Example of usage. public class Foo{ private FixedFormatManager fixed = new FixedFormatManagerImpl(); // .. Add code to open the text file and read each line with readLine(). private MyRecord readLine(BufferedReader in){ MyRecord r = fixed.load(MyRecord.class,in.ReadLine()); return r; } } [edit] ResourcesProject page and documentation User comments on this article (FixedFormat4j) |
||
Very limited usage. But it indeed does the work and you don't need to reinvent the wheel. The annotation st