Search:

Type: Posts; User: Norm

Search: Search took 0.09 seconds.

  1. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    If you want to exit a while loop you can use the break statement.
  2. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Did you add a println to print out a message every time the reg command is executed?
    How many times did it print out a message that the reg command was being executed?
  3. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    How many times was the inner loop executed?
    How many times do you want it to execute?

    I don't understand why there is an inner loop that can be executed more than one time.
    Every time it is...
  4. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    How many lines does the code read in the loop? What are on those lines?
    Are there 5 lines with the same data?
    How many times does the loop execute?

    You need to debug your code to see how it is...
  5. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    I can not tell without seeing the full contents of all the lines.
    You need to print out many values to see what is happening. See post#32 where I suggested some things to print out.
  6. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    The third element is an empty String. What is in the rest of the array?
    See the end of post #32 for how to print the contents of an array.


    Why is the println commented out? You need to see...
  7. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Are you sure? Maybe it is printing a blank line. Add an id string to the println call:

    System.out.println("[2]="+line.split(" ")[2]+"<"); // print with delimiters


    Put this line in front...
  8. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Remember when you tried using substring and got errors because the line was empty?
    Now you are having the same problem again. The code needs to look at the line to see if it is long enough.
    Also...
  9. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    This line:

    System.out.println(str.split(" ")[2]);
    will print the third element in the array that was split from the String contained in str.
    The contents of str would be what was read into the...
  10. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    What did that program do? Did it get the part of the String that you want?


    Can you identify what line has the data so you can use split to extract the part you want?
    Pseudo code:
    begin loop...
  11. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Did you write a small simple testing program as I suggested in post #18?

    Use that to try the different methods to find methods that will help you parse the String that is shown in post#18.

    The...
  12. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Post the code and its output that shows what you have tried. You could be very close and only need a small change to get it to work.
  13. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Did you try what I suggested in post#18? Post the code for the small testing program you used that tried the different String class methods
  14. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Time to do some experimenting. Write a small simple program that defines a String:

    String str = "Certified REG_SZ Pos001";
    Then use different String class methods to scan and split and search...
  15. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Count the lines as they are read.
    Use one of the String class's methods.
  16. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Do you see now what you need to do? You need to consider the String's length before trying to take a substring of it.


    The printlns could be:



    System.out.println("len=" + line.length() +...
  17. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    The String class has a method that returns the length of the String. Print out what it returns.
  18. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    It looks like there are two blank lines printed. You need to print the length of each String when the String is printed.
  19. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    When you print out the String by itself without the substring, how many lines are printed?
    Are some of the lines very short? Include the String's length in the print out.
  20. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Post the full contents of the error message.
    Add a println to print out its value, execute the code and post the contents of the console from when it is executed.

    To copy the contents of the...
  21. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    Is the data you want in a String?
    The String class has many methods for searching a String and getting a substring from it.

    Where is the data located in the String? What search method would...
  22. Replies
    44
    Views
    2,250

    Re: Print just what I want, help me with my code.

    If what you show is in a String, you can scan the String and extract a substring from it to print.
Results 1 to 22 of 22