📄 wordfile.java
字号:
package java.lancs ;/** * extension of BasicFileIo for Exercise 18.4 * @author Roger Garside * @version Last Rewritten: 24/Sept/97 */import java.io.* ;import java.util.* ;import java.lancs.* ;public class WordFile extends BasicFileIo { StringTokenizer currentLine = null ; /** * Constructor for WordFile * Initialises the filetype to "unknown". */ public WordFile() { super() ; } // end of constructor method /** * Constructor for WordFile * @param t The filetype - either INPUT or OUPUT * @param name The filename as a string * @throws IOException If there is a problem opening the file */ public WordFile(int t, String name) throws IOException { super(t, name) ; } // end of constructor method /** * reads the next word from the file * @return the next word (whitespace-separated) from the file, or null */ public String readWord() throws IOException { while ((currentLine == null) || (!currentLine.hasMoreTokens())) { String s = readString() ; if (s == null) return null ; currentLine = new StringTokenizer(s, " \t\n\r") ; } return currentLine.nextToken() ; } // end of method readWord } // end of class WordFile
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -