Character stream read data - by a single character read
Create a character stream read file object:
Reader reader = new FileReader("readme.txt");
Call the method of reading data:
int Data reader.Read = (); // read a character, the character represented by an integer, when the end of the stream is reached, -1
Character stream read data - by character array read
Create a character stream read file object:
Reader reader = new FileReader("readme.txt");
Call the method of reading data:
// read into an array of characters, number of characters read, if the end of the stream is reached, it returns -1 char [] = CHS new new char [2048 ]; int len = r.read (CHS);
Character stream to write data - by a single character written
Create a character stream file object to write:
Writer writer = new FileWriter("dest.txt");
Call the method of writing data:
int X = 'in' ; writer.Write (X); // write a character
Character stream to write data - by character array write
Create a character stream file object to write:
Writer writer = new FileWriter("dest.txt")
Call the method of writing data (write array of characters):
char [] = {CHS 'orange', 'heart', 'orange', 'meaning' }; writer.Write (CHS); // write a character array
Calling a method of writing data (writing string):
writer.write ( "black love learning"); // write a string
Character stream copy files - by a single character reader
Create a character stream read file object:
Reader reader = new FileReader("readme.txt");
Create a character stream file object to write:
Writer writer = new FileWriter("dest.txt");
Call the method of reading data:
int data = reader.read();
Call the method of writing data:
writer.write(data);
Character stream copy files - by character array reader
Create a character stream read file object:
Reader reader = new FileReader("readme.txt");
Create a character stream file object to write:
Writer writer = new FileWriter("dest.txt");
Call the method of reading data:
char[] chs = new char[2048]; int len = reader.read(chs);
Call the method of writing data:
writer.write(chs);
Basic usage character stream operational data presentation.thank. In the actual production environment, the operation flow is very slow, time-consuming (open resources, operating resources, close
resources), so the actual production flow operating environment of high demand for efficiency. For this reason, the Java designers provides an efficient buffered stream for developers to make
use, next essay introduction!