title: Modify ByteArrayOutputStream .write value later in Java
body: <p>Is there any way to change the value of ByteArrayOutputStream .write later on in the code? (Please note the comment in the code below)</p>
  
  <p>Something similar like:</p>
  
  <pre><code>public class test {
      public static int val;
      public static void main(String args[]) {
  
          ByteArrayOutputStream outgoingStream = new ByteArrayOutputStream();
          outgoingStream.write(1);
          outgoingStream.write(92);
          val = 23;
          outgoingStream.write(val);
          outgoingStream.write(34);
          val = 69;
  
  
          byte[] bytes = outgoingStream.toByteArray();
  
          ByteArrayInputStream in = new ByteArrayInputStream(bytes);
  
          for(int i = 0; i&lt;bytes .length;i++) {
              //Outputs 1 92 23 34 but I need it as 1 92 69 34
              System.out.println(in.read());
          }   
      }
  
  }
  </code></pre>