List of usage examples for org.apache.commons.io.output NullOutputStream close
public void close() throws IOException
From source file:com.jaspersoft.jasperserver.core.util.TolerantObjectWrapper.java
/** * tests whether an object is serializable * * return boolean representing if it is serializable * * *///ww w.j av a 2 s.c om private boolean testIsSerializable(Object obj) throws IOException { NullOutputStream nos = new NullOutputStream(); ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(nos); oos.writeObject(obj); oos.close(); nos.close(); } catch (Exception err) { return false; } return true; }
From source file:org.rhq.storage.installer.StorageInstaller.java
private String exec(File workingDir, org.apache.commons.exec.CommandLine cmdLine) throws Exception { Executor executor = new DefaultExecutor(); org.apache.commons.io.output.ByteArrayOutputStream buffer = new org.apache.commons.io.output.ByteArrayOutputStream(); NullOutputStream nullOs = new NullOutputStream(); PumpStreamHandler streamHandler = new PumpStreamHandler(nullOs, buffer); executor.setWorkingDirectory(workingDir); executor.setStreamHandler(streamHandler); String result = ""; try {//from ww w . j ava2 s. co m exec(executor, cmdLine); result = buffer.toString(); } finally { try { buffer.close(); nullOs.close(); } catch (Exception e) { // best effort } } return result; }