How to read x number of characters from a text file progressively
<p>I am trying to read x characters from a text file at a time, progressively. So if I had: aaaaabbbbbcccccabckcka and im reading 5 at a time I would get, aaaaa, bbbbb,ccccc, abckc and ka. The code I am using is:</p>

<pre><code>            status =  is.read(bytes);
            text = new String(bytes);
</code></pre>

<p>where bytes is: bytes = new byte[5], I am calling these two lines of code till status becomes -1, the problem I am facing is, the output is not what I have mentioned above, but I get this:</p>

<p>aaaaa, bbbbb, ccccc, abckc and kackc, notice the last segment 'kackc' is garbage, why is this happening ?</p>

<p>Note: that bytes is initialized once outside the reading loop.</p>
