Java OutputStream extend

Description

Java OutputStream extend

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

public class Main {
  public static void main(String[] args) {
    PrintStream ps = new PrintStream(new My());

    System.setOut(ps);/* w w w .ja v  a 2s. c om*/

    System.out.println("Hello world!");
  }
}

class My extends OutputStream {
  public void write(int b) throws IOException {

  }
}



PreviousNext

Related