use of php.runtime.memory.BinaryMemory in project jphp by jphp-compiler.
the class ByteArrayInputStreamMemoryOperation method unconvert.
@Override
public Memory unconvert(Environment env, TraceInfo trace, ByteArrayInputStream arg) throws Throwable {
byte[] buffer = new byte[4096];
try {
ByteBuffer result = ByteBuffer.allocate(20);
int len;
while ((len = arg.read(buffer)) > 0) {
// nop
result.put(buffer, 0, len);
}
return new BinaryMemory(result.array());
} catch (IOException e) {
throw new CriticalException(e);
}
}
Aggregations