You are on page 1of 1

public class WordIterator { char charToReturn=null; String word; public WordIterator (String fileLocation) { FileReader f = new FileReader(fileLocation) } public

void initIterator( ) { f.init( ); charToReturn=f.readChar( ); word = ""; } public boolean hasNext( ) { if (charToReturn == null) { return false; } return true } public int next( ) { String rtn=""; while (this.hasNext( ) && charToReturn!=" ") { word += charToReturn; charToReturn = f.readChar( ); } rtn=word; word=""; return rtn; } }

You might also like