Java .indexOf() >=0 seems not to be always true
<p>I am working in sustaining a project. The customer is having a problem in opening our application which has error:</p>

<pre><code>line 30 char 3 error object expected code 0 : url:http:\\localhost:5000/content.html
</code></pre>

<p>As this is not reproducible in our lab I went through the code where <code>contentPage</code> is generated:</p>

<pre><code>for ( int i = 0; i &lt; 4; ++i ) {
     socket = serverSocket.accept();
     String line = new BufferedReader( new InputStreamReader(
               socket.getInputStream(), "UTF-8")).readLine();

     if ( line.indexOf("content") &gt;= 0 ) {
          contentPage(new PrintStream(socket.getOutputStream(), false));
     }  
</code></pre>

<p>} // end of for loop.....</p>

<p>Line is a String here.</p>

<p>It seems that for the error scenario the <code>if</code> condition becomes false, so it does not enter in the <code>if</code> loop. In the success scenario it enters in the <code>if</code> loop.</p>

<p>I am new to <em>Java</em>, according to me the <code>if</code> block should always execute as "content" is a String, so <code>line.indexOf("content") &gt;= 0</code> is always true. If not, then how can I print the content? I tried <code>br.write("Content Page: : : "+contentPage(printStream out));</code> but I'm getting a compilation error.</p>
