Format the File contained in a constructed Fmt object
String w, f;
int col = 0;
while ((w = in.readLine()) != null) {
if (w.length() == 0) { // null line
System.out.print("\n"); // end current line
if (col>0) {
System.out.print("\n"); // output blank line
col = 0;
}
continue;
}
// otherwise it's text, so format it.
StringTokenizer st = new StringTokenizer(w);
while (st.hasMoreTokens()) {
f = st.nextToken();
if (col + f.length() > COLWIDTH) {
System.out.print("\n");
col = 0;
}
System.out.print(f + " ");
col += f.length() + 1;
}
}
if (col>0) System.out.print("\n");
in.close();