Parsing and writing flat files with Flatworm
I will not even try to apologize for forgetting about this place. It’s useless….
Recently I´ve working a lot with flat files. You know, parsing and writing them from/to objects. My first try was very ad hoc since I was using a very simple format. Unfortunately things changed and the need for several types of formats form multiple clients appeared.
Luckily I found a nice java library (named Flatworm) for parsing and writing files using a format defined in a XML file.
The project seems to be abandoned but it’s quite usable. You can read a fast guide to it in its home page.
Flatworm basically let you define a format with many fields (with a fixed length or using a separator ) which will be mapped to a bean fields. This way, if you write a bean to a file each field will be filled using the appropiate get method. It works the same way parsing, calling a set method for every field in the format.
I will not write a tutorial about it since the guide is quite easy to follow.
Greetings.
Twitter
LinkedIn
Facebook
Google Profile
Flickr
Leave a Reply