title: Scala bufferedinput stream reader
body: <p>I have a scala program as below</p>
  
  <pre><code>object TestApp {
    def main(args: Array[String]): Unit = {
      val in = new BufferedInputStream(new FileInputStream("testBytes.txt"))
      val buffer = Array.ofDim[Byte](15)
      while (in.read(buffer)&gt;0) {
        println(new String(buffer))
      }
    }
  }
  </code></pre>
  
  <p>The input file contains "AAAAAAAAAABBBBBBBBBB" </p>
  
  <p>When I run this program I'm getting the below results</p>
  
  <pre><code>AAAAAAAAAABBBBB
  BBBBBAAAAABBBBB
  </code></pre>
  
  <p>I'm confused why the buffer keeps old read data still, Or any way to avoid this?</p>
  
  <p>I'm expecting something like this</p>
  
  <pre><code>AAAAAAAAAABBBBB
  BBBBB
  </code></pre>