我有以下代碼來從我的文件中檢索數據。當我執行代碼時,我知道它只給出總線上50%的線。爲什麼會發生?文件閱讀:獲取部分輸出
public static void main(String args[]) throws IOException
{
int count = 1;
try {
FileInputStream fileInput = new FileInputStream("C:/FaceProv.log");
DataInputStream dataInput = new DataInputStream(fileInput);
InputStreamReader inputStr = new InputStreamReader(dataInput);
BufferedReader bufRead = new BufferedReader(inputStr);
while(bufRead.readLine() != null)
{
System.out.println("Count "+count+" : "+bufRead.readLine());
count++;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
修復將字符串行; while((line = bufRead.readLine())!= null),刪除第二條readline。 – 2012-02-11 18:55:32