private void addLine() { string nextLine = ""; while (nextLine.Length < lineLength && it.more()) { string word = it.next(); nextLine = nextLine + " " + word; } allLines.Add(nextLine); }
private int lineLength; // the (approximate) length of the formatted lines // constructs the document, all at once, where // filename is the path to the textfile on the disk, and // lineLength is the approximate length of the formatted lines public AllDoc(string filename, int lineLength) { this.lineLength = lineLength; allLines = new List <string>(); it = new WordIterator(filename); while (it.more()) { addLine(); } it.close(); }