FileDocCategorySizeDatePackage
NullOutputStream.javaAPI DocExample537Fri Feb 03 13:50:12 GMT 2006com.elharo.io

NullOutputStream.java

package com.elharo.io;

import java.io.*;

public class NullOutputStream extends OutputStream {

  private boolean closed = false;  
    
  public void write(int b) throws IOException {
    if (closed) throw new IOException("Write to closed stream");
  }
  
  public void write(byte[] data, int offset, int length) 
   throws IOException {
    if (data == null) throw new NullPointerException("data is null");
    if (closed) throw new IOException("Write to closed stream");
  }
  
  public void close() {
    closed = true;   
  }   
}