Results 1 to 8 of 8
  1. #1
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default Starting to read a file from row N ?

    How can I start reading a text file with java starting from row N ? And ignoring all previous rows ? This is my current code:

    reader = new BufferedReader(new FileReader(file));
    String row = null;
    while ((row = reader.readLine()) != null) {
    ...

    thanks

  2. #2
    BOJANM is offline Member
    Join Date
    Mar 2011
    Posts
    7
    Rep Power
    0

    Default

    try to use count++ and count=rowstart just start read!
    while (startrow) { break } - or if row(count)=startrow { break}
    start read

  3. #3
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    Sorry, I didn't get it at all. Is there a way to cut an array and get only the first N elements without using a for loop '

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You can use System.arraycopy to copy only a portion of an array, but what does this and for loops have to do with your original question?

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Just loop through the file, Have a count variable. If count == n then start actually reading the strings. In the loop have a condition where if count is greater than n you do something with the read string.

  6. #6
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    OK, sorry I mixed another question :)

  7. #7
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    Is there a way to cut an array and get only the first N elements without using a for loop
    you already asked about this in your other post! read the answers

    keep the first N elements of an array only

  8. #8
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    I know, that's why I wrote I made a mistake by replying to my other question on this thread.

Similar Threads

  1. Read a file and converting this file into a string
    By kostinio in forum New To Java
    Replies: 7
    Last Post: 12-26-2009, 03:54 PM
  2. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  3. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  4. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 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
  •