try { tree.write(tmp, bb); bb.close();
private void execute() throws IOException, ClientProtocolException { if (resp == null) if (entity != null) { if (req instanceof HttpEntityEnclosingRequest) { HttpEntityEnclosingRequest eReq = (HttpEntityEnclosingRequest) req; eReq.setEntity(entity); } resp = getClient().execute(req); entity.getBuffer().close(); entity = null; } else resp = getClient().execute(req); }
private void execute() throws IOException, ClientProtocolException { if (resp == null) if (entity != null) { if (req instanceof HttpEntityEnclosingRequest) { HttpEntityEnclosingRequest eReq = (HttpEntityEnclosingRequest) req; eReq.setEntity(entity); } resp = getClient().execute(req); entity.getBuffer().close(); entity = null; } else resp = getClient().execute(req); }
private static byte[] readFully(final InputStream is) throws IOException { TemporaryBuffer b = new TemporaryBuffer.Heap(Integer.MAX_VALUE); b.copy(is); b.close(); return b.toByteArray(); }
/** * Execute a command defined by a {@link ProcessBuilder}. * * @param pb * The command to be executed * @param in * The standard input stream passed to the process * @return The result of the executed command * @throws InterruptedException * @throws IOException * @since 4.2 */ public ExecutionResult execute(ProcessBuilder pb, InputStream in) throws IOException, InterruptedException { TemporaryBuffer stdout = new TemporaryBuffer.LocalFile(null); TemporaryBuffer stderr = new TemporaryBuffer.Heap(1024, 1024 * 1024); try { int rc = runProcess(pb, stdout, stderr, in); return new ExecutionResult(stdout, stderr, rc); } finally { stdout.close(); stderr.close(); } }
public void close() throws IOException { super.close();
public void close() throws IOException { super.close();
try { tree.write(tmp, bb); bb.close();
try { tree.write(tmp, bb); bb.close();