+ Reply to Thread
Results 1 to 2 of 2

Thread: read every fourth line with a loop

  1. #1

    read every fourth line with a loop

    examine every fourth line read.

    This is the code I already have on this problem:
    Code:
    BufferedReader br = new BufferedReader(new FileReader("file.txt"));
    String line;
    
    while ((line = br.readLine()) != null)
    {
        ...
    }
    
    br.close();

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    35
    Just call br.readLine() 3 times at the end of the loop, discarding the output:
    Code:
    BufferedReader br = new BufferedReader(new FileReader("Customers.txt"));
    String line;
    
    while ((line = br.readLine()) != null)
    {
        ...
        for(int i=0;i<3;i++){ br.readLine(); }
    }
    
    br.close();

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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