Results 1 to 2 of 2

Thread: Reading a file

  1. #1
    Ranu is offline Member
    Join Date
    Jun 2010
    Posts
    13
    Rep Power
    0

    Default Reading a file

    When I read the number of lines in a file using Scanner/FileReader the output is always two more than the real total number.For e.g.,
    I am new to java
    I have started liking the languge.

    The output is 4 instead of 2.Why is that?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Ranu View Post
    When I read the number of lines in a file using Scanner/FileReader the output is always two more than the real total number.For e.g.,
    I am new to java
    I have started liking the languge.

    The output is 4 instead of 2.Why is that?
    Print out each line (between clearly visible markers) and see what your program actually read.

    kind regards,

    Jos

Similar Threads

  1. Reading a .doc file
    By ujjal.ruet in forum New To Java
    Replies: 1
    Last Post: 05-11-2010, 09:14 PM
  2. Replies: 9
    Last Post: 10-20-2009, 10:52 AM
  3. Replies: 3
    Last Post: 05-09-2009, 11:31 PM
  4. Reading a doc file
    By thehero in forum Advanced Java
    Replies: 0
    Last Post: 03-15-2009, 06:48 AM
  5. Reading from csv file.plz help!!!!!!!!!!
    By sanjayksaini in forum New To Java
    Replies: 1
    Last Post: 12-19-2008, 07:41 AM

Posting Permissions

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