當前位置:編程學習大全網 - 網站源碼 - 為什麽我用java讀取txt文件怎麽就讀取了壹半?下面是我的源代碼

為什麽我用java讀取txt文件怎麽就讀取了壹半?下面是我的源代碼

我之前寫的壹個。妳自己修剪壹下。願幫得上妳

public static void InInputFile(String fileName){

File file = new File(fileName);

BufferedReader reader = null;

try {

reader = new BufferedReader(new FileReader(file));

String tempString = null;

int line = 1;

// 壹次讀入壹行,直到讀入null為文件結束

while ((tempString = reader.readLine()) != null) {

syso(tempString);

line++;//行數

}

reader.close();

} catch (IOException e) {

e.printStackTrace();

} finally {

if (reader != null) {

try {

reader.close();

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

}

  • 上一篇:為什麽我百度貼吧設計頭像,發帖的時候,怎麽不顯示頭像?
  • 下一篇:如何修改php分離的html模板
  • copyright 2024編程學習大全網