Reading a file and check whether the lines end with semicolon
<p>I read a text file which contains the following code.</p>

<pre><code>void main()
{
    int A = 5 ;
    float B = 6 
    double C ; 
    C = A + B ;
    cout &lt;&lt; C ; 
}
</code></pre>

<p>I wanted to loop through the lines of code and check if each line ends with a semicolon(;).</p>

<p>I wrote the following code and ran it on NetBeans IDE.</p>

<pre><code>int lineCount = 0;

BufferedReader ReadFile = new BufferedReader(new FileReader("C:\\ReadFile2.txt"));

while ((CurrentLine = ReadFile.readLine()) != null)
{
    lineCount++;
    if (CurrentLine.endsWith(";"))
    {

    }
    else
    {
        jTextArea2.append("Error at line" + " " + lineCount);                   
    }

}
</code></pre>

<p>After running the code, the output wasn't as it suppose to be.
This was the output</p>

<pre>
Error at line 1 
Error at line 2
Error at line 4 
Error at line 5 
Error at line 7
Error at line 8
</pre>
