java讀取文件

import java.io.File;

File file = new File(path);
if (file.exists()) {
			try {
				BufferedReader read = new BufferedReader(new FileReader(file));
				while (read.readLine() != null) {//本例中是想讀取文件的行數
					//sum++;
				}

		

				read.close();

			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			// System.out.println(path + "存在");

		} else {
			// System.out.println(path + "不存在");
		}
	}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章