我讀文件的Java,使用此代碼:在java中讀取文件時如何檢測我們有一行?
File file = new File(--path-);
Scanner reader= new Scanner(file);
while(reader.hasNext()){
// i want to add here if reader.Next() == emptyline
// I tried if reader.Next()=="" but it did not work.
}
謝謝大家
你試過了嗎if(reader.hasNextLine())'?請閱讀[API文檔](http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#hasNextLine()) – BackSlash