@SuppressWarnings("unchecked")
public static <T> T parseObject(InputStream is,
Charset charset,
Type type,
ParserConfig config,
ParseProcess processor,
int featureValues,
Feature... features) throws IOException {
if (charset == null) {
charset = IOUtils.UTF8;
}
byte[] bytes = allocateBytes(1024 * 64);
int offset = 0;
for (;;) {
int readCount = is.read(bytes, offset, bytes.length - offset);
if (readCount == -1) {
break;
}
offset += readCount;
if (offset == bytes.length) {
byte[] newBytes = new byte[bytes.length * 3 / 2];
System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
bytes = newBytes;
}
}
return (T) parseObject(bytes, 0, offset, charset, type, config, processor, featureValues, features);
}