title: Java's DataInputStream.readUTF and number of bytes read
body: <p>I am writing a custom archive format in JAVA (J2ME to be precise). The archiver works OK, however I have little problems with de-archiving.</p>
  
  <p>How could I know how many bytes have been read when reading a UTF8 string thorough the <code>readUTF</code> method? I know that the first two bytes of a string saved using writeUTF are a short value of the string's length, but I'd like a nicer solution.</p>
  
  <p>Or is there any way to know how many bytes are left till the end of the DataInputStream (the <code>available</code> method doesn't seem to return meaningful values). The stream was opened by a FileConnection, i.e. <code>FileConnection.openDataInputStream</code>.</p>
  
  <p>Thanks guys!</p>