hereral/Clara-Training-Data huggingface dataset:
Question: What are the Java DataOutputStream class methods?
Answer: Methods of Java DataOutputStream class 
Method: int size()
Description: It is used to return the number of bytes written to the data output stream.

Method: void write(int b)
Description: It is used to write the specified byte to the underlying output stream.

Method: void write(byte[] b, int off, int len)
Description: It is used to write len bytes of data to the output stream.

Method: void writeBoolean(boolean v)
Description: It is used to write Boolean to the output stream as a 1-byte value.

Method: void writeChar(int v)
Description: It is used to write char to the output stream as a 2-byte value.

Method: void writeChars(String s)
Description: It is used to write string to the output stream as a sequence of characters.

Method: void writeByte(int v)
Description: It is used to write a byte to the output stream as a 1-byte value.

Method: void writeBytes(String s)
Description: It is used to write string to the output stream as a sequence of bytes.

Method: void writeInt(int v)
Description: It is used to write an int to the output stream

Method: void writeShort(int v)
Description: It is used to write a short to the output stream.

Method: void writeShort(int v)
Description: It is used to write a short to the output stream.

Method: void writeLong(long v)
Description: It is used to write a long to the output stream.

Method: void writeUTF(String str)
Description: It is used to write a string to the output stream using UTF-8 encoding in portable manner.

Method: void flush()
Description: It is used to flushes the data output stream.
Question: What is Java DataInputStream Class?
Answer: Java DataInputStream class allows an application to read primitive data from the input stream in a machine-independent way.

Java application generally uses the data output stream to write data that can later be read by a data input stream.
Question: What is the declaration for Java DataInputStream?
Answer: Let's see the declaration for java.io.DataInputStream class:

public class DataInputStream extends FilterInputStream implements DataInput
Question: What are the Java DataInputStream class Methods?
Answer: Methods of Java DataInputStream class
Method: int read(byte[] b)
Description: It is used to read the number of bytes from the input stream.

Method: int read(byte[] b, int off, int len)	
Description: It is used to read len bytes of data from the input stream.

Method: int readInt()	
Description: It is used to read input bytes and return an int value.

Method: byte readByte()	
Description: It is used to read and return the one input byte.

Method: char readChar()	
Description: It is used to read two input bytes and returns a char value.

Method: double readDouble()	
Description: It is used to read eight input bytes and returns a double value.

Method: boolean readBoolean()	
Description: It is used to read one input byte and return true if byte is non zero, false if byte is zero.

Method: int skipBytes(int x)	
Description: It is used to skip over x bytes of data from the input stream.

Method: String readUTF()	
Description: It is used to read a string that has been encoded using the UTF-8 format.

Method: void readFully(byte[] b)	
Description: It is used to read bytes from the input stream and store them into the buffer array.

Method: void readFully(byte[] b, int off, int len)	
Description: It is used to read len bytes from the input stream.
Question: What is Java FilterOutputStream Class?
Answer: Java FilterOutputStream class implements the OutputStream class. It provides different sub classes such as BufferedOutputStream and DataOutputStream to provide additional functionality. So it is less used individually.
Question: What isi the class declaration for Java FilterOutputStream?
Answer: Let's see the declaration for java.io.FilterOutputStream class:

public class FilterOutputStream extends OutputStream
Question: What are the Java FilterOutputStream class Methods?
Answer: Methods of Java FilterOutputStream class
Method:	void write(int b)
Description: It is used to write the specified byte to the output stream.

Method:	void write(byte[] ary)	
Description: It is used to write ary.length byte to the output stream.

Method:	void write(byte[] b, int off, int len)	
Description: It is used to write len bytes from the offset off to the output stream.

Method:	void flush()	
Description: It is used to flushes the output stream.

Method:	void close()	
Description: It is used to close the output stream.
Question: What is Java FilterInputStream Class?
Answer: Java FilterInputStream class implements the InputStream. It contains different sub classes as BufferedInputStream, DataInputStream for providing additional functionality. So it is less used individually.
Question: What is the class declaration for Java FilterInputStream?
Answer: Let's see the declaration for java.io.FilterInputStream class


public class FilterInputStream extends InputStream
Question: What are the Java FilterInputStream class Methods?
Answer: Methods of Java FilterInputStream class 
Method: int available()	
Description: It is used to return an estimate number of bytes that can be read from the input stream.

Method: int read()	
Description: It is used to read the next byte of data from the input stream.

Method: int read(byte[] b)	
Description: It is used to read up to byte.length bytes of data from the input stream.

Method: long skip(long n)	
Description: It is used to skip over and discards n bytes of data from the input stream.

Method: boolean markSupported()	
Description: It is used to test if the input stream support mark and reset method.

Method: void mark(int readlimit)	
Description: It is used to mark the current position in the input stream.

Method: void reset()	
Description: It is used to reset the input stream.

Method: void close()	
Description: It is used to close the input stream.
Question: What is Java - ObjectStreamClass?
Answer: ObjectStreamClass act as a Serialization descriptor for class. This class contains the name and serialVersionUID of the class.
Question: What is Java ObjectStreamField class?
Answer: Fields of Java - ObjectStreamClass
Modifier and Type: static ObjectStreamField[]
Field: NO_FIELDS	
Description: serialPersistentFields value indicating no serializable fields
Question: What is Java Console Class?
Answer: The Java Console class is be used to get input from console. It provides methods to read texts and passwords.

If you read password using Console class, it will not be displayed to the user.

The java.io.Console class is attached with system console internally. The Console class is introduced since 1.5.
Question: What is the class declaration for Java Console?
Answer: Let's see the declaration for Java.io.Console class:

public final class Console extends Object implements Flushable
Question: What are the Java Console class methods?
Answer: Methods of Java Console class 
Method: Reader reader()
Description: 	It is used to retrieve the reader object associated with the console

Method: String readLine()
Description: It is used to read a single line of text from the console.

Method: String readLine(String fmt, Object... args)	
Description: It provides a formatted prompt then reads the single line of text from the console.

Method: char[] readPassword()	
Description: It is used to read password that is not being displayed on the console.

Method: char[] readPassword(String fmt, Object... args)	
Description: It provides a formatted prompt then reads the password that is not being displayed on the console.

Method: Console format(String fmt, Object... args)	
Description: It is used to write a formatted string to the console output stream.

Method: Console printf(String format, Object... args)	
Description: It is used to write a string to the console output stream.

Method: PrintWriter writer()	
Description: It is used to retrieve the PrintWriter object associated with the console.

Method: void flush()	
Description: It is used to flushes the console.
Question: How to get the object of Console?
Answer: System class provides a static method console() that returns the singleton instance of Console class.

public static Console console(){}   
Let's see the code to get the instance of Console class.

Console c=System.console();
Question: Can you give me a Java Console Example?
Answer: import java.io.Console;  
class ReadStringTest{    
public static void main(String args[]){    
Console c=System.console();    
System.out.println("Enter your name: ");    
String n=c.readLine();    
System.out.println("Welcome "+n);    
}    
}  


Output:

Enter your name: Nakul Jain
Welcome Nakul Jain
Question: Can you give me a Java Console Example to read password?
Answer: import java.io.Console;  
class ReadPasswordTest{    
public static void main(String args[]){    
Console c=System.console();    
System.out.println("Enter password: ");    
char[] ch=c.readPassword();    
String pass=String.valueOf(ch);//converting char array into string    
System.out.println("Password is: "+pass);    
}    
} 
 
Output:

Enter password: 
Password is: 123
Question: What is Java FilePermission Class?
Answer: Java FilePermission class contains the permission related to a directory or file. All the permissions are related with path. The path can be of two types:

1) D:\\IO\\-: It indicates that the permission is associated with all sub directories and files recursively.

2) D:\\IO\\*: It indicates that the permission is associated with all directory and files within this directory excluding sub directories.
Question: What is the class declaration for Java FilePermission?
Answer: Let's see the declaration for Java.io.FilePermission class:


public final class FilePermission extends Permission implements Serializable
Question: What are the Methods of FilePermission class?
Answer: Methods of FilePermission class
Method:	ByteArrayOutputStream()	
Description: Creates a new byte array output stream with the initial capacity of 32 bytes, though its size increases if necessary.

Method: ByteArrayOutputStream(int size)	
Description: Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
Question: What are the Java FilePermission class methods?
Answer: Methods of Java FilePermission class 
Method: int hashCode()	
Description: It is used to return the hash code value of an object.

Method: String getActions()	
Description: It is used to return the "canonical string representation" of an action.

Method: boolean equals(Object obj)	
Description: It is used to check the two FilePermission objects for equality.

Method: boolean implies(Permission p)	
Description: It is used to check the FilePermission object for the specified permission.

Method: PermissionCollection newPermissionCollection()	
Description: It is used to return the new PermissonCollection object for storing the FilePermission object.
Question: Can you give me a Java FilePermission Example?
Answer: Let's see the simple example in which permission of a directory path is granted with read permission and a file of this directory is granted for write permission.

package com.javatpoint;  
  
import java.io.*;  
import java.security.PermissionCollection;  
public class FilePermissionExample{  
       public static void main(String[] args) throws IOException {  
        String srg = "D:\\IO Package\\java.txt";  
        FilePermission file1 = new FilePermission("D:\\IO Package\\-", "read");  
        PermissionCollection permission = file1.newPermissionCollection();  
        permission.add(file1);  
             FilePermission file2 = new FilePermission(srg, "write");  
             permission.add(file2);  
             if(permission.implies(new FilePermission(srg, "read,write"))) {  
             System.out.println("Read, Write permission is granted for the path "+srg );  
             }else {  
            System.out.println("No Read, Write permission is granted for the path "+srg);            }  
       }   
}  


Output:

Read, Write permission is granted for the path D:\IO Package\java.txt
Question: What is Java Writer?
Answer: It is an abstract class for writing to character streams. The methods that a subclass must implement are write(char[], int, int), flush(), and close(). Most subclasses will override some of the methods defined here to provide higher efficiency, functionality or both.
Question: Can you give me a Java Writer Example?
Answer: import java.io.*;  
public class WriterExample {  
    public static void main(String[] args) {  
        try {  
            Writer w = new FileWriter("output.txt");  
            String content = "I love my country";  
            w.write(content);  
            w.close();  
            System.out.println("Done");  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
}  

Output:

Done
output.txt:

I love my country
Question: What is Java Reader?
Answer: Java Reader is an abstract class for reading character streams. The only methods that a subclass must implement are read(char[], int, int) and close(). Most subclasses, however, will override some of the methods to provide higher efficiency, additional functionality, or both.

Some of the implementation class are BufferedReader, CharArrayReader, FilterReader, InputStreamReader, PipedReader, StringReader
Question: What is Java FileWriter Class?
Answer: Java FileWriter class is used to write character-oriented data to a file. It is character-oriented class which is used for file handling in java.

Unlike FileOutputStream class, you don't need to convert string into byte array because it provides method to write string directly.
Question: What is the declaration for Java FileWriter?
Answer: Let's see the declaration for Java.io.FileWriter class:

public class FileWriter extends OutputStreamWriter
Question: What are the Constructors of FileWriter class?
Answer: Constructors of FileWriter class
Constructor: FileWriter(String file)		
Description: Creates a new file. It gets file name in string.

Constructor: FileWriter(File file)	
Description: Creates a new file. It gets file name in File object.
Question: What are the Methods of FileWriter class?
Answer: Methods of FileWriter class
Method:	void write(String text)
Description: It is used to write the string into FileWriter.
	
Method:	void write(char c)
Description: It is used to write the char into FileWriter.

Method:	void write(char[] c)
Description: It is used to write char array into FileWriter.

Method:	void flush()
Description: It is used to flushes the data of FileWriter.

Method:	void close()
Description: It is used to close the FileWriter.
Question: Can you give mee a Java FileWriter Example?
Answer: In this example, we are writing the data in the file testout.txt using Java FileWriter class.
package com.javatpoint;  
import java.io.FileWriter;  
public class FileWriterExample {  
    public static void main(String args[]){    
         try{    
           FileWriter fw=new FileWriter("D:\\testout.txt");    
           fw.write("Welcome to javaTpoint.");    
           fw.close();    
          }catch(Exception e){System.out.println(e);}    
          System.out.println("Success...");    
     }    
}  

Output:


Success...
testout.txt:

Welcome to javaTpoint.
Question: What is Java FileReader Class?
Answer: Java FileReader class is used to read data from the file. It returns data in byte format like FileInputStream class.

It is character-oriented class which is used for file handling in java.
Question: What is Java FileReader class declaration?
Answer: Let's see the declaration for Java.io.FileReader class:

public class FileReader extends InputStreamReader
Question: Can you give me the Constructors of FileReader class?
Answer: Constructors of FileReader class
Constructor: FileReader(String file)	
Description: It gets filename in string. It opens the given file in read mode. If file doesn't exist, it throws FileNotFoundException.
	
Constructor: FileReader(File file)	
Description: It gets filename in file instance. It opens the given file in read mode. If file doesn't exist, it throws FileNotFoundException.
Question: Can you provide the Methods of FileReader class?
Answer: Methods of FileReader class
Method:	int read()
Description: It is used to return a character in ASCII form. It returns -1 at the end of file.

Method:	void close()
Description: It is used to close the FileReader class.
Question: Can you give me the Java FileReader Example?
Answer: In this example, we are reading the data from the text file testout.txt using Java FileReader class.

package com.javatpoint;  
  
import java.io.FileReader;  
public class FileReaderExample {  
    public static void main(String args[])throws Exception{    
          FileReader fr=new FileReader("D:\\testout.txt");    
          int i;    
          while((i=fr.read())!=-1)    
          System.out.print((char)i);    
          fr.close();    
    }    
}    
Here, we are assuming that you have following data in "testout.txt" file:


Welcome to javaTpoint.

Output:

Welcome to javaTpoint.
Question: What is Java BufferedWriter Class?
Answer: Java BufferedWriter class is used to provide buffering for Writer instances. It makes the performance fast. It inherits Writer class. The buffering characters are used for providing the efficient writing of single arrays, characters, and strings.
Question: What is Java BufferedWriter Class declaration?
Answer: Let's see the declaration for Java.io.BufferedWriter class:


public class BufferedWriter extends Writer
Question: Can you give me an Example of Java BufferedWriter?
Answer: Let's see the simple example of writing the data to a text file testout.txt using Java BufferedWriter.

package com.javatpoint;  
import java.io.*;  
public class BufferedWriterExample {  
public static void main(String[] args) throws Exception {     
    FileWriter writer = new FileWriter("D:\\testout.txt");  
    BufferedWriter buffer = new BufferedWriter(writer);  
    buffer.write("Welcome to javaTpoint.");  
    buffer.close();  
    System.out.println("Success");  
    }  
}  


Output:

success

testout.txt:

Welcome to javaTpoint.
Question: What is Java BufferedReader Class?
Answer: Java BufferedReader class is used to read the text from a character-based input stream. It can be used to read data line by line by readLine() method. It makes the performance fast. It inherits Reader class.
Question: What is Java BufferedReader class declaration?
Answer: Let's see the declaration for Java.io.BufferedReader class:


public class BufferedReader extends Reader
Question: Can you provide the Java BufferedReader class constructors?
Answer: Constructors of Java BufferedReader class 
Constructor: BufferedReader(Reader rd)	
Description: It is used to create a buffered character input stream that uses the default size for an input buffer.
	
Constructor: BufferedReader(Reader rd, int size)	
Description: It is used to create a buffered character input stream that uses the specified size for an input buffer.
Question: Can you give me the Java BufferedReader class methods?
Answer: Methods of Java BufferedReader class 
Method:	int read()
Description: It is used for reading a single character.

Method: int read(char[] cbuf, int off, int len)
Description: It is used for reading characters into a portion of an array.

Method: boolean markSupported()
Description: It is used to test the input stream support for the mark and reset method.

Method: String readLine()
Description: It is used for reading a line of text.

Method: boolean ready()
Description: It is used to test whether the input stream is ready to be read.

Method: long skip(long n)
Description: It is used for skipping the characters.

Method: void reset()
Description: It repositions the stream at a position the mark method was last called on this input stream.

Method: void mark(int readAheadLimit)
Description: It is used for marking the present position in a stream.
	
Method: void close()
Description: It closes the input stream and releases any of the system resources associated with the stream.
Question: Can you provide the Java BufferedReader Example?
Answer: In this example, we are reading the data from the text file testout.txt using Java BufferedReader class.

package com.javatpoint;  
import java.io.*;  
public class BufferedReaderExample {  
    public static void main(String args[])throws Exception{    
          FileReader fr=new FileReader("D:\\testout.txt");    
          BufferedReader br=new BufferedReader(fr);    
  
          int i;    
          while((i=br.read())!=-1){  
          System.out.print((char)i);  
          }  
          br.close();    
          fr.close();    
    }    
}    
Here, we are assuming that you have following data in "testout.txt" file:


Welcome to javaTpoint.

Output:

Welcome to javaTpoint.
Question: What is Java CharArrayReader Class?
Answer: The CharArrayReader is composed of two words: CharArray and Reader. The CharArrayReader class is used to read character array as a reader (stream). It inherits Reader class.
Question: What is Java CharArrayReader class declaration?
Answer: Let's see the declaration for Java.io.CharArrayReader class:


public class CharArrayReader extends Reader
Question: Can you give me the Java CharArrayReader class methods?
Answer: Methods of Java CharArrayReader class 
Method: int read()
Description: It is used to read a single character

Method:  int read(char[] b, int off, int len)
Description: It is used to read characters into the portion of an array.

Method: boolean ready()
Description: It is used to tell whether the stream is ready to read.

Method: boolean markSupported()        
Description: It is used to tell whether the stream supports mark() operation.

Method: long skip(long n)
Description: It is used to skip the character in the input stream.

Method: void mark(int readAheadLimit)
Description: It is used to mark the present position in the stream.

Method: void reset()
Description: It is used to reset the stream to a most recent mark.

Method:        void close()
Description: It is used to closes the stream.
Question: Can you provide an Example of CharArrayReader Class?
Answer: Let's see the simple example to read a character using Java CharArrayReader class.

package com.javatpoint;  
  
import java.io.CharArrayReader;  
public class CharArrayExample{  
  public static void main(String[] ag) throws Exception {  
    char[] ary = { 'j', 'a', 'v', 'a', 't', 'p', 'o', 'i', 'n', 't' };  
    CharArrayReader reader = new CharArrayReader(ary);  
    int k = 0;  
    // Read until the end of a file  
    while ((k = reader.read()) != -1) {  
      char ch = (char) k;  
      System.out.print(ch + " : ");  
      System.out.println(k);  
    }  
  }  
}  


Output:

j : 106
a : 97
v : 118
a : 97
t : 116
p : 112
o : 111
i : 105
n : 110
t : 116
Question: What is Java CharArrayWriter Class?
Answer: The CharArrayWriter class can be used to write common data to multiple files. This class inherits Writer class. Its buffer automatically grows when data is written in this stream. Calling the close() method on this object has no effect.
Question: What is Java CharArrayWriter class declaration?
Answer: Let's see the declaration for Java.io.CharArrayWriter class:


public class CharArrayWriter extends Writer
Question: Can you give me the Java CharArrayWriter class Methods?
Answer: Methods of Java CharArrayWriter class 
Method: int size()
Description: It is used to return the current size of the buffer.

Method: char[] toCharArray()
Description: It is used to return the copy of an input data.

Method: String toString()
Description: It is used for converting an input data to a string.

Method: CharArrayWriter append(char c)
Description: It is used to append the specified character to the writer.

Method: CharArrayWriter append(CharSequence csq)
Description: It is used to append the specified character sequence to the writer.

Method: CharArrayWriter append(CharSequence csq, int start, int end)
Description: It is used to append the subsequence of a specified character to the writer.

Method: void write(int c)
Description: It is used to write a character to the buffer.

Method: void write(char[] c, int off, int len)
Description: It is used to write a character to the buffer.

Method: void write(String str, int off, int len)
Description: It is used to write a portion of string to the buffer.

Method: void writeTo(Writer out)
Description: It is used to write the content of buffer to different character stream.

Method: void flush()
Description: It is used to flush the stream.

Method: void reset()
Description: It is used to reset the buffer.

Method: void close()
Description: It is used to close the stream.
Question: Can you provide an Example of CharArrayWriter Class?
Answer: In this example, we are writing a common data to 4 files a.txt, b.txt, c.txt and d.txt.

package com.javatpoint;  
  
import java.io.CharArrayWriter;  
import java.io.FileWriter;  
public class CharArrayWriterExample {  
public static void main(String args[])throws Exception{    
          CharArrayWriter out=new CharArrayWriter();    
          out.write("Welcome to javaTpoint");    
          FileWriter f1=new FileWriter("D:\\a.txt");    
          FileWriter f2=new FileWriter("D:\\b.txt");    
          FileWriter f3=new FileWriter("D:\\c.txt");    
          FileWriter f4=new FileWriter("D:\\d.txt");    
          out.writeTo(f1);    
          out.writeTo(f2);    
          out.writeTo(f3);    
          out.writeTo(f4);    
          f1.close();    
          f2.close();    
          f3.close();    
          f4.close();    
          System.out.println("Success...");    
         }    
        }        


Output

Success…

After executing the program, you can see that all files have common data: Welcome to javaTpoint.
a.txt:
Welcome to javaTpoint

b.txt:
Welcome to javaTpoint

c.txt:
Welcome to javaTpoint

d.txt:
Welcome to javaTpoint
Question: What is Java PrintStream Class?
Answer: The PrintStream class provides methods to write data to another stream. The PrintStream class automatically flushes the data so there is no need to call flush() method. Moreover, its methods don't throw IOException.
Question: What is Java PrintStream Class declaration?
Answer: Let's see the declaration for Java.io.PrintStream class:

public class PrintStream extends FilterOutputStream implements Closeable. Appendable
Question: Can you provide the Methods of PrintStream class?
Answer: void print(boolean b) - It prints the specified boolean value.
void print(char c) - It prints the specified char value.
void print(char[] c) - It prints the specified character array values.
void print(int i) - It prints the specified int value.
void print(long l) - It prints the specified long value.
void print(float f) - It prints the specified float value.
void print(double d) - It prints the specified double value.
void print(String s) - It prints the specified string value.
void print(Object obj) - It prints the specified object value.
void println(boolean b) - It prints the specified boolean value and terminates the line.
void println(char c) - It prints the specified char value and terminates the line.
void println(char[] c) - It prints the specified character array values and terminates the line.
void println(int i) - It prints the specified int value and terminates the line.
void println(long l) - It prints the specified long value and terminates the line.
void println(float f) - It prints the specified float value and terminates the line.v
void println(double d) - It prints the specified double value and terminates the line.
void println(String s) - It prints the specified string value and terminates the line.
void println(Object obj) - It prints the specified object value and terminates the line.
void println() - It terminates the line only. 
void printf(Object format, Object... args) - It writes the formatted string to the current stream.
void printf(Locale l, Object format, Object... args) - It writes the formatted string to the current stream.
void format(Object format, Object... args) - It writes the formatted string to the current stream using specified format.
void format(Locale l, Object format, Object... args) - It writes the formatted string to the current stream using specified format.
Question: Can you give me an Example of java PrintStream class?
Answer: In this example, we are simply printing integer and string value.

package com.javatpoint;  
  
import java.io.FileOutputStream;  
import java.io.PrintStream;  
public class PrintStreamTest{    
 public static void main(String args[])throws Exception{    
   FileOutputStream fout=new FileOutputStream("D:\\testout.txt ");
  PrintStream pout=new PrintStream(fout);    
   pout.println(2016);    
   pout.println("Hello Java");    
   pout.println("Welcome to Java");    
   pout.close();    
   fout.close();    
  System.out.println("Success?");    
 }    
}	


Output
Success...

The content of a text file testout.txt is set with the below data
2016
Hello Java
Welcome to Java
Question: Can you give me an Example of printf() method using java PrintStream class?
Answer: Let's see the simple example of printing integer value by format specifier using printf() method of java.io.PrintStream class.

class PrintStreamTest{    
 public static void main(String args[]){    
   int a=19;    
   System.out.printf("%d",a); //Note: out is the object of printstream       
 }    
}   

Output
19
Question: What is Java PrintWriter class?
Answer: Java PrintWriter class is the implementation of Writer class. It is used to print the formatted representation of objects to the text-output stream.
Question: What is Java PrintWriter class declaration?
Answer: Let's see the declaration for Java.io.PrintWriter class:

public class PrintWriter extends Writer
Question: Can you give me the Methods of PrintWriter class?
Answer: void println(boolean x) - It is used to print the boolean value.
void println(char[] x) - It is used to print an array of characters.
void println(int x) - It is used to print an integer.
PrintWriter append(char c) - It is used to append the specified character to the writer.
PrintWriter append(CharSequence ch) - It is used to append the specified character sequence to the writer.
PrintWriter append(CharSequence ch, int start, int end) - It is used to append a subsequence of specified character to the writer.
boolean checkError() - It is used to flushes the stream and check its error state.
protected void setError() - It is used to indicate that an error occurs.
protected void clearError() - It is used to clear the error state of a stream.
PrintWriter format(String format, Object... args) - It is used to write a formatted string to the writer using specified arguments and format string.
void print(Object obj) - It is used to print an object.
void flush() - It is used to flushes the stream.
void close() - It is used to close the stream.
Question: Can you provide the Java PrintWriter Example?
Answer: Let's see the simple example of writing the data on a console and in a text file testout.txt using Java PrintWriter class.

package com.javatpoint;  
  
import java.io.File;  
import java.io.PrintWriter;  
public class PrintWriterExample {  
    public static void main(String[] args) throws Exception {  
             //Data to write on Console using PrintWriter  
      PrintWriter writer = new PrintWriter(System.out);    
      writer.write("Javatpoint provides tutorials of all technology.");        
 writer.flush();  
      writer.close();  
//Data to write in File using PrintWriter       
      PrintWriter writer1 =null;      
         writer1 = new PrintWriter(new File("D:\\testout.txt"));  
         writer1.write("Like Java, Spring, Hibernate, Android, PHP etc.");                                                   
                         writer1.flush();  
         writer1.close();  
    }  
} 


Outpt
Javatpoint provides tutorials of all technology.

The content of a text file testout.txt is set with the data Like Java, Spring, Hibernate, Android, PHP etc.
Question: What is Java OutputStreamWriter?
Answer: OutputStreamWriter is a class which is used to convert character stream to byte stream, the characters are encoded into byte using a specified charset. write() method calls the encoding converter which converts the character into bytes. The resulting bytes are then accumulated in a buffer before being written into the underlying output stream. The characters passed to write() methods are not buffered. We optimize the performance of OutputStreamWriter by using it with in a BufferedWriter so that to avoid frequent converter invocation.
Question: Can you provide the Java OutputStreamWriter Constructor?
Answer: OutputStreamWriter(OutputStream out) - It creates an OutputStreamWriter that uses the default character encoding. 
OutputStreamWriter(OutputStream out, Charset cs) - It creates an OutputStreamWriter that uses the given charset.
OutputStreamWriter(OutputStream out, CharsetEncoder enc) - It creates an OutputStreamWriter that uses the given charset encoder.
OutputStreamWriter(OutputStream out, String charsetName) - It creates an OutputStreamWriter that uses the named charset.
Question: Can you give me the Java OutputStreamWriter Methods?
Answer: Modifier and type: void
Method: close()
Description: It closes the stream, flushing it first.

Modifier and type: void
Method:  flush()
Description: It flushes the stream

Modifier and type: String
Method: getEncoding()
Description: It returns the name of the character encoding being used by this stream.

Modifier and type: void
Method: write(char[] cbuf, int off, int len)
Description: It writes a portion of an array of characters.

Modifier and type: void
Method:  write(int c)
Description: It writes a single character.

Modifier and type: void
Method: write(String str, int off, int len)
Description: It writes a portion of a string.
Question: Can you provide the Java OutputStreamWriter example?
Answer: public class OutputStreamWriterExample {  
    public static void main(String[] args) {  
  
        try {  
            OutputStream outputStream = new FileOutputStream("output.txt");  
            Writer outputStreamWriter = new OutputStreamWriter(outputStream);  
  
            outputStreamWriter.write("Hello World");  
  
            outputStreamWriter.close();  
        } catch (Exception e) {  
            e.getMessage();  
        }  
    }  
}  

Output:
output.txt file will contains text  "Hello World"
Question: What is Java InputStreamReader?
Answer: An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.
Question: Can you give me the Java InputStreamReader constructor?
Answer: Constructor name:  InputStreamReader(InputStream in)
 Description: It creates an InputStreamReader that uses the default charset.

Constructor name: InputStreamReader(InputStream in, Charset cs)
 Description: It creates an InputStreamReader that uses the given charset. 

Constructor name: InputStreamReader(InputStream in, CharsetDecoder dec)
 Description: It creates an InputStreamReader that uses the given charset decoder

Constructor name: InputStreamReader(InputStream in, String charsetName)
 Description: It creates an InputStreamReader that uses the named charset.
Question: Can you provide the Java InputStreamReader method?
Answer: Modifier and type: void
Method: close() 
Description: It closes the stream and releases any system resources associated with it.

Modifier and type: String 
Method: getEncoding() 
Description: It returns the name of the character encoding being used by this stream.

Modifier and type:int 
Method: read() 
Description: It reads a single character.

Modifier and type: int
Method: read(char[] cbuf, int offset, int length)
Description: It reads characters into a portion of an array.

Modifier and type: boolean
Method: ready()
Description:  It tells whether this stream is ready to be read.
Question: Can you give me the Java InputStreamReader example?
Answer: public class InputStreamReaderExample {  
    public static void main(String[] args) {  
        try  {  
            InputStream stream = new FileInputStream("file.txt");  
            Reader reader = new InputStreamReader(stream);  
            int data = reader.read();  
            while (data != -1) {  
                System.out.print((char) data);  
                data = reader.read();  
            }  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  
}  

Output:
I love my country

The file.txt contains text "I love my country" the InputStreamReader 
reads Character by character from the file
Question: What is Java PushbackInputStream Class?
Answer: Java PushbackInputStream class overrides InputStream and provides extra functionality to another input stream. It can unread a byte which is already read and push back one byte.
Question: What is Java PushbackInputStream Class declaration?
Answer: Let's see the declaration for java.io.PushbackInputStream class:
public class PushbackInputStream extends FilterInputStream
Question: Can you give me the Java PushbackInputStream Class methods?
Answer:  It is used to test if the input stream support mark and reset method.

int available() - It is used to return the number of bytes that can be read from the input stream.
int read() -  It is used to read the next byte of data from the input stream.
boolean markSupported() 
void mark(int readlimit) - It is used to mark the current position in the input stream.
long skip(long x) - It is used to skip over and discard x bytes of data.
void unread(int b) - It is used to pushes back the byte by copying it to the pushback buffer.
void unread(byte[] b) - It is used to pushes back the array of byte by copying it to the pushback buffer.
void reset() -  It is used to reset the input stream.
void close() -  It is used to close the input stream.
Question: Can you provide an Example of PushbackInputStream class?
Answer: import java.io.*;  
public class InputStreamExample {  
public static void main(String[] args)throws Exception{  
          String srg = "1##2#34###12";  
          byte ary[] = srg.getBytes();  
          ByteArrayInputStream array = new ByteArrayInputStream(ary);  
          PushbackInputStream push = new PushbackInputStream(array);  
          int i;        
              while( (i = push.read())!= -1) {  
                  if(i == '#') {  
                      int j;  
                      if( (j = push.read()) == '#'){  
                           System.out.print("**");  
                      }else {  
                          push.unread(j);  
                          System.out.print((char)i);  
                      }  
                  }else {  
                              System.out.print((char)i);  
                  }  
             }        
  }   
} 

Output:
1**2#34**#12
Question: What is Java PushbackReader Class?

Answer: Java PushbackReader class is a character stream reader. It is used to pushes back a character into stream and overrides the FilterReader class.
Question: What is Java PushbackReader Class declaration?
Answer: Let' s see the declaration for java.io.PushbackReader class:
public class PushbackReader extends FilterReader
Question: Can you give me the Java PushbackReader Class methods?
Answer: int read() - It is used to read a single character.
void mark(int readAheadLimit) - It is used to mark the present position in a stream.
boolean ready()  - It is used to tell whether the stream is ready to be read.
boolean markSupported() - It is used to tell whether the stream supports mark() operation.
long skip(long n) - It is used to skip the character.
void unread (int c) - It is used to pushes back the character by copying it to the pushback buffer.
void unread (char[] cbuf) - It is used to pushes back an array of character by copying it to the pushback buffer.
void reset() - It is used to reset the stream
void close() - It is used to close the stream.
Question: Can you provide an Example of PushbackReader class?
Answer: import java.io.*;  
public class ReaderExample{  
    public static void main(String[] args) throws Exception {  
        char ary[] = {'1','-','-','2','-','3','4','-','-','-','5','6'};  
        CharArrayReader reader = new CharArrayReader(ary);   
        PushbackReader push = new PushbackReader(reader);  
        int i;  
            while( (i = push.read())!= -1) {  
                if(i == '-') {  
                    int j;  
                    if( (j = push.read()) == '-'){  
                         System.out.print("#*");  
                    }else {  
                        push.unread(j); // push back single character  
                        System.out.print((char)i);  
                    }  
                }else {  
                        System.out.print((char)i);  
                }  
           }         
    }  
}  

Output
1#*2-34#*-56
Question: What is Java StringWriter Class?
Answer: Java StringWriter class is a character stream that collects output from string buffer, which can be used to construct a string. The StringWriter class inherits the Writer class.

In StringWriter class, system resources like network sockets and files are not used, therefore closing the StringWriter is not necessary.
Question: What is Java StringWriter class declaration?
Answer: Let's see the declaration for Java.io.StringWriter class:
public class StringWriter extends Writer
Question: Can you give me the Methods of StringWriter class?
Answer: void write(int c) -  It is used to write the single character.
void write(String str) -  It is used to write the string.
void write(String str, int off, int len) -  It is used to write the portion of a string.
void write(char[] cbuf, int off, int len) -  It is used to write the portion of an array of characters.
String toString() - It is used to return the buffer current value as a string.
StringBuffer getBuffer() -  It is used t return the string buffer.
StringWriter append(char c) - It is used to append the specified character to the writer.
StringWriter append(CharSequence csq)-  It is used to append the specified character sequence to the writer.
StringWriter append(CharSequence csq, int start, int end)-  It is used to append the subsequence of specified character sequence to the writer.
void flush() -  It is used to flush the stream.
void close() - It is used to close the stream.
Question: Can you provide the Java StringWriter Example?
Answer: Let's see the simple example of StringWriter using BufferedReader to read file data from the stream.

import java.io.*;  
public class StringWriterExample {  
    public static void main(String[] args) throws IOException {  
        char[] ary = new char[512];  
        StringWriter writer = new StringWriter();  
        FileInputStream input = null;  
        BufferedReader buffer = null;  
        input = new FileInputStream("D://testout.txt");  
        buffer = new BufferedReader(new InputStreamReader(input, "UTF-8"));  
        int x;  
        while ((x = buffer.read(ary)) != -1) {  
                   writer.write(ary, 0, x);  
        }  
        System.out.println(writer.toString());        
        writer.close();  
        buffer.close();  
    }  
}  

testout.txt:
Javatpoint provides tutorial in Java, Spring, Hibernate, Android, PHP etc.

Output:
Javatpoint provides tutorial in Java, Spring, Hibernate, Android, PHP etc
Question: What is Java StringReader Class?
Answer: Java StringReader class is a character stream with string as a source. It takes an input string and changes it into character stream. It inherits Reader class.

In StringReader class, system resources like network sockets and files are not used, therefore closing the StringReader is not necessary.
Question: What is Java StringReader class declaration?
Answer: Let's see the declaration for Java.io.StringReader class:
public class StringReader extends Reader
Question: Can you give me the Methods of StringReader class?
Answer: int read() - It is used to read a single character.
int read(char[] cbuf, int off, int len) -It is used to read a character into a portion of an array.
boolean ready() - It is used to tell whether the stream is ready to be read.
boolean markSupported() - It is used to tell whether the stream support mark() operation.
long skip(long ns)-It is used to skip the specified number of character in a stream
void mark(int readAheadLimit) - It is used to mark the mark the present position in a stream.
void reset()- It is used to reset the stream.
void close()- It is used to close the stream.
Question: Can you provide the Java StringReader Example?
Answer: import java.io.StringReader;  
public class StringReaderExample {  
    public static void main(String[] args) throws Exception {  
        String srg = "Hello Java!! \nWelcome to Javatpoint.";  
        StringReader reader = new StringReader(srg);  
        int k=0;  
            while((k=reader.read())!=-1){  
                System.out.print((char)k);  
            }  
        }  
}  

Output:
Hello Java!! 
Welcome to Javatpoint.
Question: What is Java - PipedWriter?
Answer: The PipedWriter class is used to write java pipe as a stream of characters. This class is used generally for writing text. Generally PipedWriter is connected to a PipedReader and used by different threads.
Question: What is Java - PipedWriter constructor?
Answer: Constructor: PipedWriter() 
Description: It creates a piped writer that is not yet connected to a piped reader.

Constructor: PipedWriter(PipedReader snk)
Description: It creates a piped writer connected to the specified piped reader.
Question: Can you give me the Java - PipedWriter method?
Answer: Modifier and Type: void
Method: close()
Description: It closes this piped output stream and releases any system resources associated with this stream.

Modifier and Type: void
Method: connect(PipedReader snk)
Description: It connects this piped writer to a receiver.

Modifier and Type: void
Method:flush()
Description: It flushes this output stream and forces any buffered output characters to be written out.

Modifier and Type: void
Method: write(char[] cbuf, int off, int len)
Description: It writes len characters from the specified character array starting at offset off to this piped output stream.

Modifier and Type: void
Method: write(int c)
Description: It writes the specified char to the piped output stream.
Question: Can you provide the Java - PipedWriter example?
Answer: import java.io.PipedReader;  
import java.io.PipedWriter;  
  
public class PipeReaderExample2 {  
    public static void main(String[] args) {  
        try {  
  
            final PipedReader read = new PipedReader();  
            final PipedWriter write = new PipedWriter(read);  
  
            Thread readerThread = new Thread(new Runnable() {  
                public void run() {  
                    try {  
                        int data = read.read();  
                        while (data != -1) {  
                            System.out.print((char) data);  
                            data = read.read();  
                        }  
                    } catch (Exception ex) {  
                    }  
                }  
            });  
  
            Thread writerThread = new Thread(new Runnable() {  
                public void run() {  
                    try {  
                        write.write("I love my country\n".toCharArray());  
                    } catch (Exception ex) {  
                    }  
                }  
            });  
  
            readerThread.start();  
            writerThread.start();  
  
        } catch (Exception ex) {  
            System.out.println(ex.getMessage());  
        }  
  
    }  
}  


Output:
I love my country
Question: What is Java - PipedReader?
Answer: The PipedReader class is used to read the contents of a pipe as a stream of characters. This class is used generally to read text.

PipedReader class must be connected to the same PipedWriter and are used by different threads.