Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use.
488447
static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf,
            int offset, int limit, boolean bufferRecyclable, IOContext context)
            throws IOException
    {
        return new UTF8StreamJsonParser(context,
                DEFAULT_JSON_FACTORY.getParserFeatures(), in,
                DEFAULT_JSON_FACTORY.getCodec(),
                DEFAULT_JSON_FACTORY.getRootByteSymbols().makeChild(1),
                buf, offset, limit, bufferRecyclable);
    }
396032
public static String getString(ByteBuffer buf, int offset, int length, Charset encoding) {
        buf = buf.duplicate();
        buf.position(buf.position() + offset);
        if (buf.hasArray()) {
            return new String(buf.array(), buf.arrayOffset() + buf.position(), length, encoding);
        } else {
            byte[] bytes = new byte[length];
            buf.get(bytes);
            return new String(bytes, encoding);
        }
    }
661875
function bufferToArrayBuffer(buf) {
  const arr = new ArrayBuffer(buf.length);
  const view = new Uint8Array(arr);
  for (let i = 0; i < buf.length; ++i) {
    view[i] = buf[i];
  }
  return arr;
}
576265
private JsonParserException createParseException(Exception e, String message, boolean tokenPos) {
    if (tokenPos)
      return new JsonParserException(e, message + " on line " + tokenLinePos + ", char " + tokenCharPos,
          tokenLinePos, tokenCharPos, tokenCharOffset);
    else {
      int charPos = Math.max(1, index - rowPos - utf8adjust);
      return new JsonParserException(e, message + " on line " + linePos + ", char " + charPos, linePos, charPos,
          index + charOffset);
    }
  }
136511
@SuppressWarnings("unchecked")
  @Override
  public T decode(final byte[] buf) {
    try (final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf))) {
      return (T) in.readObject();
    } catch (final ClassNotFoundException | IOException ex) {
      throw new RemoteRuntimeException(ex);
    }
  }
345843
@Override
    public Parser newDelimitedParser(final InputStream dataSourceStream, final char delimiter, final char qualifier) {
        return new DelimiterParser(dataSourceStream, delimiter, qualifier, false);
    }
1322877
public static byte[] inputStreamToBytes(InputStream in) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            byte[] buffer = new byte[1024];
            int len;
            while ((len = in.read(buffer)) != -1) {
                out.write(buffer, 0, len);
            }
        } catch (Exception e) {
            System.out.println("Error converting InputStream to byte[]: "
                    + e.getMessage());
        }
        return out.toByteArray();
    }
757345
function toArrayBuffer(buf) {
  if (buf instanceof ArrayBuffer) {
    return buf;
  } else if (Buffer.isBuffer(buf)) {
    return bufferToArrayBuffer(buf);
  } else if (buf instanceof Uint8Array) {
    return bufferToArrayBuffer(buf);
  } else {
    return buf; // type unknown, trust the user
  }
}
83918
function toBuffer(buf) {
  if (buf instanceof ArrayBuffer) {
    return arrayBufferToBuffer(buf);
  } else if (Buffer.isBuffer(buf)) {
    return buf;
  } else if (buf instanceof Uint8Array) {
    return new Buffer(buf);
  } else {
    return buf; // type unknown, trust the user
  }
}
1107829
public static ByteBuffer bytes(String s)
	    {
	    	if(s==null)
	    		return null;
	        return ByteBuffer.wrap(s.getBytes(UTF_8));
	    }
190310
function toArrayBuffer(buf) {
  if (buf.byteLength === buf.buffer.byteLength) {
    return buf.buffer;
  }

  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
}
688535
public byte[] toCompressedJSON() throws IOException {
        // Wrap a GZIPOuputStream around a ByteArrayOuputStream.
        ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        GZIPOutputStream gzipOut = new GZIPOutputStream(bytesOut);
        
        // Wrap the GZIPOutputStream with an OutputStreamWriter that convers JSON Unicode
        // text to bytes using UTF-8.
        OutputStreamWriter writer = new OutputStreamWriter(gzipOut, Utils.UTF8_CHARSET);
        
        // Create a JSONEmitter that will write its output to the writer above and generate
        // the JSON output.
        JSONEmitter json = new JSONEmitter(writer);
        json.startDocument();
        toJSON(json);
        json.endDocument();
        
        // Ensure the output stream is flushed and the GZIP is finished, then the output
        // buffer is complete.
        writer.flush();
        gzipOut.finish();
        return bytesOut.toByteArray();
    }
370376
public <T> T parse(InputStream in, JsonReaderI<T> mapper) throws ParseException, UnsupportedEncodingException {
		InputStreamReader i2 = new InputStreamReader(in, "utf8");
		//
		return super.parse(i2, mapper);
	}
768204
public static String byteBufferToString(ByteBuffer buf) {
    StringBuilder sb = new StringBuilder();
    for (int k = 0; k < buf.limit() / 4; k++) {
      if (k != 0) {
        sb.append(" ");
      }
      sb.append(buf.getInt());
    }
    return sb.toString();
  }
1374631
public <T> T deserialize(final InputStream stream, final int bufferSize) {
    ByteBufferInput in = new ByteBufferInput(stream, bufferSize);
    Kryo kryo = borrow();
    try {
      @SuppressWarnings("unchecked")
      T obj = (T) kryo.readClassAndObject(in);
      return obj;
    } finally {
      release(kryo);
    }
  }
992037
public static ByteBuffer cloneByteBuffer(ByteBuffer buf) {
    ByteBuffer ret = ByteBuffer.allocate(buf.limit() - buf.position());
    if (buf.hasArray()) {
      ret.put(buf.array(), buf.position(), buf.limit() - buf.position());
    } else {
      // direct buffer
      ret.put(buf);
    }
    ret.flip();
    return ret;
  }
473191
public static ByteBuf copiedBuffer(CharSequence string, Charset charset) {
        if (string == null) {
            throw new NullPointerException("string");
        }

        if (string instanceof CharBuffer) {
            return copiedBuffer((CharBuffer) string, charset);
        }

        return copiedBuffer(CharBuffer.wrap(string), charset);
    }