Character stream: Characters-based when reading and writing files
Byte input stream: Reader abstract class common subclass: FileReader
Usage: int read (char "" C,int Off,int Len)
Byte output stream: Writer abstract class common subclass: FileWriter
Usage: void writer (char "" C, int off,int len)
Demo
Package test;
Import java.io.*;
public class Testchar {
public static void Main (String args []) {
FileReader filereader = null;
FileWriter FileWriter = null;
char c [] = new char[100];
try {
FileReader = new FileReader ("/users/ningyu/desktop/from.txt");
FileWriter = new FileWriter ("/users/ningyu/desktop/to.txt");
while (true) {
int temp = Filereader.read (c, 0, c.length);
if (temp = =-1) {
Break
}
Filewriter.write (c, 0, c.length);
}
SYSTEM.OUT.PRINTLN (temp);
for (int i = 0;i < C.length; i++) {
System.out.println (C[i]);
}
} catch (Exception e) {
System.out.println (e);
}finally {
try {
Filereader.close ();
Filewriter.close ();
} catch (Exception E2) {
SYSTEM.OUT.PRINTLN (E2);
}
}
}
}
Android Development Character Stream