title: Reading text file in J2ME
body: <p>I'm trying to read a resource (asdf.txt), but if the file is bigger than 5000 bytes, (for example) 4700 pieces of null-character inserted to the end of the content variable. Is there any way to remove them? (or to set the right size of the buffer?)</p>
  
  <p>Here is the code:</p>
  
  <pre><code>String content = "";
  try {
      InputStream in = this.getClass().getResourceAsStream("asdf.txt");
      byte[] buffer = new byte[5000];
      while (in.read(buffer) != -1) {
          content += new String(buffer);
      }
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>