Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
int comparison always returns true?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="thomasjbs, post: 3562289"] I can't figure this out - new to java, but code appears to be ok. I'm looking for a string within lines of text returned from a system command. I get all the output back - no problem. But when I try to do something based on indexOf, it always returns true: Here is output from System.out.println statements showing the text does *not* exist in the output (and another example showing it does) Here is the code to search for it. On int tf = 0; boolean textfound = false; // Loop through lines of text with Try and readLine... { tf = inputLine.indexOf("FINDTHISSTRING"); System.out.println(tf); if ( tf > -1 ); { textfound = true; } } I also tried " tf == 0 ". Example of Failure to find Text ====================== -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Example of case where FIND text Exists: ============================== -1 -1 -1 -1 -1 -1 0 Found it here -1 0 and Here -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
int comparison always returns true?
Top