Is there a Null OutputStream in Java?
/**Writes to nowhere*/public class NullOutputStream extends OutputStream { @Override public void write(int b) throws IOException { }}
Java doesn't it would seem but Apache Commons IO does. Take a look at the following:
Hope that helps.
It's not mentioned yet, so I'll also add Guava's ByteStreams.nullOutputStream(), as some might prefer Guava over Apache Commons IO or already have it in their project.
Note: If you use an older version of Guava (from 1.0 to 13.0), you want to use com.google.io.NullOutputStream.