remove blank lines using java code

Below is my Java code which is used to create a

PDF

and print the content in the

PDF

document. I have blank lines between the printed lines as shown in the code below. If there are more than two blank lines after the printed statement, just write one blank line and omit other blank lines to write in the

PDF

document. So if there is one or two blank lines I can print it as it is, but if there are more than that then remove all extra blank lines and just add one blank line using Java code. I am using Java version 5. Please suggest.