Results 1 to 2 of 2

Thread: i need help in file class

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    23

    Red face i need help in file class

    how ican get the last line in a certain file

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: i need help in file class

    This is how you do it :-
    Code:
    import java.io.BufferedReader ;
    import java.io.FileReader ;
    import java.io.IOException ;
    
    public class LastLineReader {
      public static void main (String[] args) throws IOException {
        //A BufferedReader object can read one line at a time
        BufferedReader br = new BufferedReader(new FileReader("C:\\Text.txt")) ;
        String lastLine ;
        while (br.ready()) { //As long as there are more bits in the file
          lastLine = br.readLine() ;
        }
      }
    }
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width