I'm trying to enhance a program that reads in a flat file that conatains multiple record types and only writes/prints out the first record of each type of record in the file. I created beans for each record type because I needed to shift the order of the fields in each record before printing them out.
I am able to write out each record, but if a record has multiple rows all the rows are being printed/written to a file. Is there a way to delete the number of rows in my buffer before I execute system.out.println for a specific bean? Any other suggestions would be appreciated.
Thank you in advance for any suggestions!

Here is the code:

public class ComplexFile {
public static void main(String[] args) {
ConfigurationReader parser = new ConfigurationReader();
try {
FileFormat ff = parser.loadConfigurationFile(args[0]);
InputStream in = new FileInputStream(args[1]);
BufferedReader bufIn = new BufferedReader(new InputStreamReader(in));

MatchedRecord results;
while ((results = ff.getNextRecord(bufIn)) != null) {
if (results.getRecordName().equals("onerecord")) {
System.out.println(results.getBean("onerecord"));

}
if (results.getRecordName().equals("tworecord")) {
System.out.println(results.getBean("tworecord"));
}

if (results.getRecordName().equals("threerecord")) {
System.out.println(results.getBean("threerecord")) ;
}

if (results.getRecordName().equals("fourrecord")) {
System.out.println(results.getBean("fourrecord"));
}

if (results.getRecordName().equals("fiverecord")) {
System.out.println(results.getBean("fiverecord"));
}
if (results.getRecordName().equals("sixrecord")) {
System.out.println(results.getBean("sixrecord"));
}

}
}
catch (ComplexUnsetFieldValueException complexUnsetFieldValueError) {
complexUnsetFieldValueError.printStackTrace(); }
catch (ComplexUnsetFieldValueException ComplexUnsetFieldValueError) {
ComplexUnsetFieldValueError.printStackTrace(); }
catch (ComplexConfigurationValueException ComplexConfigurationValueError) {
ComplexConfigurationValueError.printStackTrace(); }
catch (FileNotFoundException e) {
e.printStackTrace(); }
catch (ComplexInvalidRecordException e) {
e.printStackTrace(); }
catch (ComplexInputLineLengthException e) {
e.printStackTrace(); }
catch (ComplexConversionException e) {
e.printStackTrace(); .
}
}
}