Java PrintWriter class

Java PrintWriter class is the implementation of Writer class. It is used to print the formatted representation of objects to the text-output stream.

Class declaration

public class PrintWriter extends Writer

Methods of PrintWriter class

  1. void println(boolean x)

    It is used to print the boolean value.

  2. void println(char[] x)

    It is used to print an array of characters.

  3. void println(int x)

    It is used to print an integer.

  4. PrintWriter append(char c)

    It is used to append the specified character to the writer.

  5. PrintWriter append(CharSequence ch)

    It is used to append the specified character sequence to the writer.

  6. PrintWriter append(CharSequence ch, int start, int end)

    It is used to append a subsequence of specified character to the writer.

  7. boolean checkError()

    It is used to flushes the stream and check its error state.

  8. protected void setError()

    It is used to indicate that an error occurs.

  9. protected void clearError()

    It is used to clear the error state of a stream.

  10. PrintWriter format(String format, Object... args)

    It is used to write a formatted string to the writer using specified arguments and format string.


Example :

Flash Soon


Output:



Advertisement

© Sapster 2017