本帖最后由 杨兴庭 于 2013-7-28 22:54 编辑
public void getWord() throws Exception {
BufferedReader in = new BufferedReader(new FileReader(
".\\javaIO\\fail1.txt"));
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(
".\\javaIO\\fail1_2.txt")));
String s = "";
int line = 0;
while ((s = in.readLine()) != null) {
System.out.println("现在进行到第" + ++line + "行" + s);
StringReader sr = new StringReader(s);
String word = "";
char c = (char) sr.read();
while (c != ',') {
word += c;
c = (char) sr.read();
}
pw.print(word);
pw.print("\t");
System.out.print(word + "\t");
c = (char) sr.read();
System.out.println(c);
while ((int) c != -1) {
word += c;
c = (char) sr.read();
}
pw.print(word);
pw.println();
System.out.println(word);
sr.close();
}
in.close();
pw.close();
}
|
这段代码只能读入一行,输出一行,eclipse就处于停滞状态,不会自己终止运行。
我看不明白到底哪里出错了,请各位大侠帮帮忙~~~~~ |