Character Oriented
Character-oriented is the user input and output of 16-byte Unicode characters. It is used to read and write the character. There are many sub-classes, but the most common classes are:- Reader, Writer BufferedReader, FileReader, FileWriter, InputStreamReader, etc.
a. FileReader classes: The abstract class reads characters from files using the read() method.
Syntax:-
FileReader reader=new FileReader(“file.txt”);
reader.read();
b. FileWriter classes:-It is the abstract class that writes a character into files using the write() method.
Syntax:-
FileWriter out=new FileWriter(“ouput.txt”);
out.write();
c. BufferedReader classes:- It reads characters and strings from the input stream. This class is based on buffering.
Syntax:
BufferReader b=new BufferReader(new InputStreamReader(System.in));
b.readLine();
Code Example
import java.io.*;
public class Display {
public static void main(String[] args) {
try {
Writer w = new FileWriter("infile.txt");
String content = "I love my india";
w.write(content);
w.close();
System.out.println("complete");
}
catch (IOException e) {
e.printStackTrace();
} } }
RANREV INFOTECH