1
我不明白如何使用TextIO的readFile(字符串文件名) 有人可以请解释我该如何读取外部文件?使用TextIO读取外部文件
public static void readFile(String fileName) {
if (fileName == null) // Go back to reading standard input
readStandardInput();
else {
BufferedReader newin;
try {
newin = new BufferedReader(new FileReader(fileName));
}
catch (Exception e) {
throw new IllegalArgumentException("Can't open file \"" + fileName + "\" for input.\n"
+ "(Error :" + e + ")");
}
if (! readingStandardInput) { // close current input stream
try {
in.close();
}
catch (Exception e) {
}
}
emptyBuffer(); // Added November 2007
in = newin;
readingStandardInput = false;
inputErrorCount = 0;
inputFileName = fileName;
}
}
你什么都不明白? – Miki 2014-09-20 23:19:47
如何读取外部文件。如何使用TextIO的这部分 – user2994326 2014-09-20 23:24:18
好像你必须首先调用'readFile(“/ path/to/file)',然后使用该类的输入方法,就像'getAnyChar()','getlnString()'或'getln()'。 – Tom 2014-09-20 23:31:38