title: JProgressBar from InputStream
body: <p>There are many posts on <code>JProgressBar</code>, but I can not find a solution for the following problem. How do I update <code>JProgressBar</code> measuring bytes received from <code>InputStream</code>?</p>
  
  <p>For example, I have the following code:</p>
  
  <pre><code>int bytesRead;
  byte buffer = new byte[1024];
  ByteArrayOutputStream getBytes = new ByteArrayOutputStream();
  
  while ((bytesRead = dis.read(buffer)) != -1) {
      getBytes.write(buffer, 0, bytesRead);
  }
  
  return(getBytes.toByteArray());
  </code></pre>