Page 2 of 2 FirstFirst 12
Results 21 to 36 of 36
  1. #21
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    What do you need to do to skip some more lines? There was a hint on post#13

  2. #22
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    835
    Rep Power
    6

    Default

    one more problem iam able to see here.Ur text have this type of pattern

    "Query =" or " Query = " etc etc

    Using replace function of String remove the space and then do the manipulation.

    Still u may face problems..Better to go for regex pattern matcher.
    Ramya:cool:

  3. #23
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    I tried that also, but still no luck.
    I also have tried .seek() and to jump to a certain line.
    But still nothing works....

    I there maybe anyone who has the code to do it?
    That I can look up how it works?

  4. #24
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    I gave some pseudo code in post#15
    Here it is again:
    Java Code:
    for(int i=0; i < 5; i++) {
     // put code here to Read the next line from the file
    }
    // here you will be at the 5th line following where you started from

  5. #25
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    I did that with the for loop.
    But now he (still) looks to 1 line. :(
    --> "Query= " line.

    Java Code:
     
    xD
    Last edited by Lund01; 10-13-2010 at 08:57 AM.

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Sorry, I don't see where you have code in your program to skip 5 lines after finding a line with "Query" in it.
    Can you post the contents of a small sample file you are reading and also the debug print out from your program when you execute your program and have it read from that sample file. Add comments to the post describing what the program should output.

  7. #27
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    There are parts in the file that look like this:

    Java Code:
     
    xD
    But the file also contains that there are Query= who where a hit. So there is a large number of information on the place where it says ***** No hits found *****.

    What I here would like as an output is:


    Java Code:
     
    xD
    I would like him to print "Test Geslaagd" (means: Test Succeded) So I can see he did find a match 5 lines lower.
    At the end he needs to put the number to a certain file, but that depends if the line ***** No hits found ***** is there or not.
    But that is not the case yet, now I just want him to see if there was a match or not. And if yes, print Test Geslaagd.

    If I look in my Java book them it also says I need to put the for(int i=0; i < 5; i++) { in. And I did, just under the try statement.
    Last edited by Lund01; 10-13-2010 at 08:58 AM.

  8. #28
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Sorry, I don't understand your last post.
    I don't see any of the debug output showing the "Skipping" messages for the 5 skipped lines.

  9. #29
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    If I activated that skipping line, then I get:

    Query= GKX6QYI01AELDC length=77 xy=0049_0286 region=1
    skipping: Query= GKX6QYI01AELDC length=77 xy=0049_0286 region=1<
    run=R_2010_07_22_08_19_36_
    Length=77


    ***** No hits found *****

    Do you meen that?

  10. #30
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Yes, something like that.
    Why was only one line skipped, I thought you wanted to skip 5.
    Way was the line with the Query= on it skipped? I thought that it was the lines After that which were to be skipped???

    Add some debug print outs to your code to show ALL of the lines as they are read and what is done to each line.
    Some lines will have the "query" string and there should be a message saying it was found.
    Some lines will be skipped, the message should say this line was skipped.

    The output from the program should show exactly what you program did with each line.
    Be sure to put ids in front of the debug output to make it different from the other output.

  11. #31
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Java Code:
     
    xD
    Edit, 13th october
    Dealeted my code since the program works ont his part. :)
    Last edited by Lund01; 10-13-2010 at 08:59 AM.

  12. #32
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Ok. Now manually create what the output should look like if the program were working the way you want it to.

    The print outs are not what I was expected. You print out the same line again and again and again.

    I thought the program was to read the lines from a file until a match was found.
    When a match is found, Then read and skip 5 lines.

    So I would expect the output to be something like this:
    Read line: <the line that was read>
    Read line: <the line that was read>
    Read line: <the line that was read. this one has QUERY>
    Found query on last line, will skip 5 lines.
    Skipping: < first of 5 lines skipped>
    ...
    Skipping: <last of 5 lines skipped>
    Read line after 5: <the line after skipping 5 lines>

  13. #33
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    So I would expect the output to be something like this:
    Read line: <the line that was read>
    Read line: <the line that was read>
    Read line: <the line that was read. this one has QUERY= >
    This he can do, for this I only need to disable the
    System.out.println("SKIP: " + line + "<<<<<<<<<<<<<<<<");
    Under the readLines.

    But he won't do the:

    Found query on last line, will skip 5 lines.
    Skipping: < first of 5 lines skipped>
    ...
    Skipping: <last of 5 lines skipped>
    Read line after 5: <the line after skipping 5 lines>

  14. #34
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Can you write a loop to read 5 lines from the file?

  15. #35
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    I an now trying getLineNumer().
    He now knows that the "Query= " line is 0.
    But how do I add 5 lines to that?

  16. #36
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    I got it!!!!
    Finally, almost drived me crazy.

    Now we have a next problem with writing it away.
    One file he does it, but the other doesn't work.....
    Ah well, tommorow another day for trying.

    Thanks for the help Norm. :)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Highlighting with exact match
    By ashkandaie in forum Lucene
    Replies: 3
    Last Post: 09-09-2010, 06:36 AM
  2. Match a word between any two HTML tags
    By mohammedsk in forum New To Java
    Replies: 7
    Last Post: 06-19-2010, 04:28 PM
  3. A crazy gui match
    By amarenash23 in forum New To Java
    Replies: 8
    Last Post: 12-30-2009, 03:39 PM
  4. Creating new instances of a Match over and over again
    By Che_Is_Alive in forum Advanced Java
    Replies: 2
    Last Post: 11-19-2009, 06:05 PM
  5. String match to the linkedlist element
    By jboy in forum New To Java
    Replies: 3
    Last Post: 09-06-2009, 07:02 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
  •