code: protected String readStringImpl(int length)
          throws IOException
      {
          StringBuffer sb = new StringBuffer();
  
          for (int i = 0; i < length; i++) {
              int ch = is.read();
  
              if (ch < 0x80)
                  sb.append((char) ch);
              else if ((ch & 0xe0) == 0xc0) {
                  int ch1 = is.read();
                  int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f);
  
                  sb.append((char) v);
              }
              else if ((ch & 0xf0) == 0xe0) {
                  int ch1 = is.read();
                  int ch2 = is.read();
                  int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
  
                  sb.append((char) v);
              }
              else
                  throw new IOException("bad utf-8 encoding");
          }
  
          return sb.toString();
      }
docs: Reads a string from the underlying stream.