30 /** 31 * This abstract class is the superclass of all classes representing 32 * an output stream of bytes. An output stream accepts output bytes 33 * and sends them to some sink. 34 * <p> 35 * Applications that need to define a subclass of 36 * <code>OutputStream</code> must always provide at least a method 37 * that writes one byte of output. 38 * 39 * @author Arthur van Hoff 40 * @see java.io.BufferedOutputStream 41 * @see java.io.ByteArrayOutputStream 42 * @see java.io.DataOutputStream 43 * @see java.io.FilterOutputStream 44 * @see java.io.InputStream 45 * @see java.io.OutputStream#write(int) 46 * @since 1.0 47 */ 48 public abstract class OutputStream implements Closeable, Flushable { 49 /** 50 * Returns a new {@code OutputStream} which discards all bytes. The 51 * returned stream is initially open. The stream is closed by calling 52 * the {@code close()} method. Subsequent calls to {@code close()} have 53 * no effect. 54 * 55 * <p> While the stream is open, the {@code write(int)}, {@code 56 * write(byte[])}, and {@code write(byte[], int, int)} methods do nothing. 57 * After the stream has been closed, these methods all throw {@code 58 * IOException}. 59 * 60 * <p> The {@code flush()} method does nothing. 61 * 62 * @return an {@code OutputStream} which discards all bytes 63 * 64 * @since 11 65 */ 66 public static OutputStream nullOutputStream() { 67 return new OutputStream() { 68 private volatile boolean closed; 69 | 30 /** 31 * This abstract class is the superclass of all classes representing 32 * an output stream of bytes. An output stream accepts output bytes 33 * and sends them to some sink. 34 * <p> 35 * Applications that need to define a subclass of 36 * <code>OutputStream</code> must always provide at least a method 37 * that writes one byte of output. 38 * 39 * @author Arthur van Hoff 40 * @see java.io.BufferedOutputStream 41 * @see java.io.ByteArrayOutputStream 42 * @see java.io.DataOutputStream 43 * @see java.io.FilterOutputStream 44 * @see java.io.InputStream 45 * @see java.io.OutputStream#write(int) 46 * @since 1.0 47 */ 48 public abstract class OutputStream implements Closeable, Flushable { 49 /** 50 * Constructor for subclasses to call. 51 */ 52 public OutputStream() {} 53 54 /** 55 * Returns a new {@code OutputStream} which discards all bytes. The 56 * returned stream is initially open. The stream is closed by calling 57 * the {@code close()} method. Subsequent calls to {@code close()} have 58 * no effect. 59 * 60 * <p> While the stream is open, the {@code write(int)}, {@code 61 * write(byte[])}, and {@code write(byte[], int, int)} methods do nothing. 62 * After the stream has been closed, these methods all throw {@code 63 * IOException}. 64 * 65 * <p> The {@code flush()} method does nothing. 66 * 67 * @return an {@code OutputStream} which discards all bytes 68 * 69 * @since 11 70 */ 71 public static OutputStream nullOutputStream() { 72 return new OutputStream() { 73 private volatile boolean closed; 74 |