If you want to exit a while loop you can use the break statement.
Type: Posts; User: Norm
If you want to exit a while loop you can use the break statement.
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?
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...
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...
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.
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...
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...
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...
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...
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...
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...
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.
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
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...
Count the lines as they are read.
Use one of the String class's methods.
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() +...
The String class has a method that returns the length of the String. Print out what it returns.
It looks like there are two blank lines printed. You need to print the length of each String when the String is printed.
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.
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...
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...
If what you show is in a String, you can scan the String and extract a substring from it to print.