check out flatworm. it will do all the magic for you, creating java objects from the text file automatically. you'll want to read about the multi-line record support, but it's in there and I think will do exactly what you're wanting