I have a program that captures a substring between two strings and returns the value instance to an arrayList, however if the value already exists or contains certain symbols I want my program to dump the string and look at the next line.
I have done this with a series of IF statements however, when my program is executed its still returning many string values that contain these character symbols.
I have tried leaving the loop blank thinking that maybe it will just abandon the string within the IF statement if the conditions aren't met. But the string values are still comming through. Another method I have tried is setting the variable value for resourceline to null. But that just causes compiler errors.
Your addition of "resourceline" to the array list is completely independent of whether or not "resourceline" contains any of the characters--it sounds like that's not what you want.
Nick Rowe
Ranch Hand
Joined: May 26, 2010
Posts: 88
posted
0
Basically if there is a value within the resourceline I want it to first trim the value and then iterate through the statements. I am expecting the If statments to search the string to see if it contains any of the symbol characters. If a character is found within the string then set the string to null (i.e dump the entire string value) and do the same thing If the value already exists within the arrayList.
Otherwise if the resourceline value does not contain any conflicting irrelevant data only then add to the array.
So how is the array being populated with all the crap IF im only adding the value after iterating through the IF statements. It just doesn't make sense to me. Surely it would only add the value If the data was correct?
regards S
Nick Rowe
Ranch Hand
Joined: May 26, 2010
Posts: 88
posted
0
I believe i just had a eureka moment.
I changed my code to the example shown below and it seems to have worked, i realise i missed the else if aswel
Why set resourceline to null? You just set it again a statement later.
Nick Rowe
Ranch Hand
Joined: May 26, 2010
Posts: 88
posted
0
I realise that there are two possibilities for this i.e. the method from the previous post and also the solution below.
I was just testing the first method at the time, and posted.
By the looks of it the only issue i have now is that the odd occurance of a single character has come through as a variable on the odd occasion.
So i need to find if the value is equal to one character and add that to the If or scenario.