Same loop giving different output. Java IO
<p>I am facing a very strange problem where the same loop keeps giving me different different output on change of value of BUFFER</p>

<pre><code>  final int BUFFER = 100;
        char[] charArr = new char[BUFFER];
        StringBuffer objStringBuffer = new StringBuffer();
        while (objBufferedReader.read(charArr, 0,BUFFER) != -1) {
            objStringBuffer.append(charArr);
        }
 objFileWriter.write(objStringBuffer.toString());
</code></pre>

<p>When i change BUFFER size to 500 it gives me a file of 7 kb when i change BUFFER size to 100000 it gives a file of 400 kb where the contents are repeated again and again. Please help. What should i do to prevent this?</p>
