import java.io.*; /** * Stupid quickie class for reading in a pure text file. * We assume that new lines are meant as paragraph markers. * Blank lines... are blank lines. I guess. * * @author Philip Brown * @version @(#) ReadText.java 2.2@(#) */ public class ReadText { /* We dont have to return anything, because it is assumed * the object passed in will become the result * * Ya know, I think we should be passed in a filename here. * * @param newDoc The object that becomes the file * @param file the file to read */ public static void ReadFile(DocInterface newDoc, String filename) throws java.io.IOException { String line; Reader file = new FileReader(filename); BufferedReader bread = new BufferedReader(file); newDoc.startInput(filename); // font #0 is always "default" newDoc.changeFont(0); while(true) { line = bread.readLine(); if(line==null) { System.out.println("got null: presuming end of file"); break; } System.out.println("read line: "+line); newDoc.addString(line); newDoc.insertParagraphBreak(); } newDoc.endInput(); } }