1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache license, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the license for the specific language governing permissions and 15 * limitations under the license. 16 */ 17 18 package org.apache.logging.log4j.core.util; 19 20 import java.io.IOException; 21 import java.io.OutputStream; 22 23 /** 24 * Writes all data to the famous <b>/dev/null</b>. 25 * <p> 26 * This output stream has no destination (file/socket etc.) and all bytes written to it are ignored and lost. 27 * </p> 28 * Originally from Apache Commons IO. 29 * 30 * @since 2.3 31 */ 32 public class NullOutputStream extends OutputStream { 33 34 /** 35 * A singleton. 36 */ 37 public static final NullOutputStream NULL_OUTPUT_STREAM = new NullOutputStream(); 38 39 /** 40 * Does nothing - output to <code>/dev/null</code>. 41 * 42 * @param b 43 * The bytes to write 44 * @param off 45 * The start offset 46 * @param len 47 * The number of bytes to write 48 */ 49 @Override 50 public void write(final byte[] b, final int off, final int len) { 51 // to /dev/null 52 } 53 54 /** 55 * Does nothing - output to <code>/dev/null</code>. 56 * 57 * @param b 58 * The byte to write 59 */ 60 @Override 61 public void write(final int b) { 62 // to /dev/null 63 } 64 65 /** 66 * Does nothing - output to <code>/dev/null</code>. 67 * 68 * @param b 69 * The bytes to write 70 * @throws IOException 71 * never 72 */ 73 @Override 74 public void write(final byte[] b) throws IOException { 75 // to /dev/null 76 } 77 }