Open In App

Java.io.Printstream Class in Java | Set 2

Last Updated : 01 May, 2024
Summarize
Comments
Improve
Suggest changes
Share
2 Likes
Like
Report
Java.io.Printstream Class in Java | Set 1

More Methods:

  • PrintStream printf(Locale l, String format, Object... args) : A convenience method to write a formatted string to this output stream using the specified format string and arguments.
    Syntax :public PrintStream printf(Locale l,
    String format,
    Object... args)
    Parameters:
    l - The locale to apply during formatting. If l is null then no localization is applied.
    format - A format string as described in Format string syntax
    args - Arguments referenced by the format specifiers in the format string.
    Returns:
    This output stream
    Throws:
    IllegalFormatException
    NullPointerException
    Output:
    GeeksforGeeks
  • PrintStream printf(String format, Object... args) : A convenience method to write a formatted string to this output stream using the specified format string and arguments.
    Syntax :public PrintStream printf(String format,
    Object... args)
    Parameters:
    format - A format string as described in Format string syntax
    args - Arguments referenced by the format specifiers in the format string.
    Returns:
    This output stream
    Throws:
    IllegalFormatException
    NullPointerException
    Output:
    GeeksforGeeks
  • void println(): Terminates the current line by writing the line separator string.
    Syntax :public void println()
    Output:
    GeeksforGeeks
  • void println(boolean x): Prints a boolean and then terminate the line.
    Syntax :public void println(boolean x)
    Output:
    true
  • void println(char x): Prints a character and then terminate the line.
    Syntax :public void println(char x)
    Output:
    g
  • void println(char[] x): Prints an array of characters and then terminate the line.
    Syntax :public void println(char[] x)
    Output:
    GEEK
  • void println(double x): Prints a double and then terminate the line.
    Syntax :public void println(double x)
    Output:
    5.42762
  • void println(float x): Prints a float and then terminate the line.
    Syntax :public void println(float x)
    Output:
    5.168502f
  • void println(int x): Prints an integer and then terminate the line.
    Syntax :public void println(boolean x)
    Output:
    5
  • void println(long x): Prints a long and then terminate the line.
    Syntax :public void println(long x)
    Output:
    123456789
  • void println(Object x) :Prints an Object and then terminate the line.
    Syntax :public void println(Object x)
    Output:
    java.io.PrintStream@15db9742
  • void println(String x) :Prints a String and then terminate the line.
    Syntax :public void println(boolean x)
    Output:
    GeeksforGeeks
  • protected void setError() :Sets the error state of the stream to true.
    Syntax :public void println(String x)
    Output:
    BCD
  • void write(byte[] buf, int off, int len) :Writes len bytes from the specified byte array starting at offset off to this stream.
    Syntax :public void write(byte[] buf,
    int off,
    int len)
    Overrides:
    write in class FilterOutputStream
    Parameters:
    buf - A byte array
    off - Offset from which to start taking bytes
    len - Number of bytes to write
    Output:
    BCD
  • void write(int b) :Writes the specified byte to this stream.
    Syntax :public void write(int b)
    Overrides:
    write in class FilterOutputStream
    Parameters:
    b - The byte to be written
    Output:
    A

Next Article
Article Tags :
Practice Tags :

Similar Reads