Java, need a while loop to reach eof. i.e.while !eof, keep parsing

前端 未结 3 562
花落未央
花落未央 2021-01-14 10:45

I currently have a working parser. It parses a file once(not what I want it to do) and then outputs parsed data into a file. I need it to keep parsing and appending to the s

3条回答
  •  执笔经年
    2021-01-14 11:34

    If you are using FileInputStream, here's an EOF method for a class that has a FileInputStream member called fis.

    public boolean isEOF() 
    { 
        try { return fis.getChannel().position() >= fis.getChannel().size()-1; } 
        catch (IOException e) { return true; } 
    }
    

提交回复
热议问题