Is there a Null OutputStream in Java?

前端 未结 11 665
灰色年华
灰色年华 2020-12-08 13:04

I need to specify an OutputStream for an API I\'m using, but I don\'t actually have a need for the output. Does Java have an OutputStream equivale

11条回答
  •  孤城傲影
    2020-12-08 13:53

    /**Writes to nowhere*/
    public class NullOutputStream extends OutputStream {
      @Override
      public void write(int b) throws IOException {
      }
    }
    

提交回复
热议问题