code: public String getString(int maxLength) throws java.io.IOException {
          String result = null;
          if (fInputStream != null) {
              StringBuilder sb = new StringBuilder();
              char[] buffer = new char[1024];
              Reader reader = getReader();
              int max = maxLength < 0? Integer.MAX_VALUE : maxLength;
              int bytesRead = 0;
  
              while ((bytesRead = reader.read(buffer, 0, Math.min(max, 1024))) >= 0) {
                  sb.append(buffer, 0, bytesRead);
                  max -= bytesRead;
              }
  
              reader.close();
  
              return sb.toString();
          } else {
              String name = getName();
              /*
               * getName() may return a name with a suffix 'rtl' or 'ltr'. This cannot
               * be used to open a charset (e.g. IBM424_rtl). The ending '_rtl' or 'ltr'
               * should be stripped off before creating the string.
               */
              int startSuffix = name.indexOf("_rtl") < 0 ? name.indexOf("_ltr") : name.indexOf("_rtl");
              if (startSuffix > 0) {
                  name = name.substring(0, startSuffix);
              }
              result = new String(fRawInput, name);
          }
          return result;
  
      }
docs: Create a Java String from Unicode character data corresponding
  to the original byte data supplied to the Charset detect operation.
  The length of the returned string is limited to the specified size;
  the string will be trunctated to this length if necessary.  A limit value of
  zero or less is ignored, and treated as no limit.
  
  @param maxLength The maximium length of the String to be created when the
  source of the data is an input stream, or -1 for
  unlimited length.
  @return a String created from the converted input data.