All About Class PrintStream in Java


A PrintStream implements an output stream filter that provides convenient methods for printing types other than byte and arrays of bytes. In addition,the PrintStream overrides many of the InputStream methods so as not to throw an IOException. Instead,an IOException causes an internal flag to be set, which the application can check by a call to the checkError() method.Only the lower 8 bits of any 16 bit quantity are printed to the stream.

Example

System.out.println("The value of y"+y);
 

The structure of class PrintStream is given as:

public class java.io.PrintStream  extends java.io.FilterOutputStream{
//constructors
public PrintStream(OutputStream out);
//constructs a new PrintStream object which writes its output to the specified underlying output Stream.
public PrintStream(OutputStream out,boolean autoFlash);
//constructs a new PrintStream object which writes its output to the specified underlying output Stream.
//In addition if the autoFlash flag is true, then the underlying output stream's flash() method is called
//and a newline character is printed.
//methods:
public Boolean checkError();
public void close();
public void flush();
public void print(boolean b);
public void println(boolean b);
public void println();
public void print(char ch);
public void println(char ch);
public void print(char ch[]);
public void println(char ch[]);
public void print(double d);
public void println(double d);
public void print(float f);
public void println(float f);
public void print(int i);
public void println(int i);
public void print(long l);
public void println(long l);
public void print(Object obj);
public void println(Object obj);
public void print(String s);
public void println(String s);
public void write(bute b[],int offset,int length);
public void write(int b);
}
 

All About Class PrintStream in Java All About Class PrintStream in Java Reviewed by Animesh Chatterjee on October 11, 2018 Rating: 5

No comments:

Powered by Blogger.