title: Java read unsigned int, store, and write it back
body: <p>I need to read an unsigned int from a quicktime file, and write it back to another quicktime file. </p>
  
  <p>Currently I read the unsigned int into a Long but while writing it back I never managed to write the exact number back in 4 bytes as unsigned int. The long has the correct value that I need to write back.
  (eg 3289763894 or 370500)
  I am unable to even read the write a number smaller then Integer.MAX_VALUE (eg 2997).</p>
  
  <p>I am using the following methods to write the value back</p>
  
  <pre><code> public void writeUInt32(long uint32,DataOutputStream stream) throws IOException {
      writeUInt16((int) (uint32 &amp; 0xffff0000) &gt;&gt; 16,stream);
      writeUInt16((int) uint32 &amp; 0x0000ffff,stream);
      }
  
  
  public void writeUInt16(int uint16,DataOutputStream stream) throws IOException {
          writeUInt8(uint16 &gt;&gt; 8, stream);
          writeUInt8(uint16, stream);
      }
  
  
      public void writeUInt8(int uint8,DataOutputStream stream) throws IOException {
          stream.write(uint8 &amp; 0xFF);
      }
  </code></pre>
  
  <p>Any help would be appreciated.  </p>