我正在輸入來自輸入(IDE eclipse Luna)的行時按下輸入光標不斷移動下來,但沒有輸出顯示。在嘗試第二種方法,但我不得不按兩次輸入打印輸出我怎樣才能解決這兩個錯誤。在只要檢測空白行第二種方法爲什麼不能打印爲什麼我需要按Enter鍵兩次,當我們按下控制檯上輸入BufferReader讀取空行
第一種方法
private static String para = null;
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(System.in));
String line;
while ((line = bufferedReader.readLine()) != null) {
para = para + line;
}
bufferedReader.close();
System.out.println(para);
}
SECOND什麼命令去方法
String line;
while (!(line = br.readLine()).equals("")) {
s1 = line.split(" ");
for (int j = 1; j < s1.length; j++) {
int m = Integer.parseInt(s1[j]);
edges[Integer.parseInt(s1[0]) - 1].add(vertices[m - 1]);
}
}
謝謝,但是,我想從控制檯讀取行將它們轉換爲單行執行一些操作,然後打印結果我不想打印行,我讀,我想把輸入在控制檯時,我按輸入它應該返回單個結果,所以有什麼解決方案在緩衝區閱讀器中? – JSONParser