Directly write the code of the class and the package itself import create, hand hit very tired
public static void Main (String args[]) {
FileReader Fr=null; File input stream
FileWriter Fw=null; File output stream
BufferedReader Br=null; Character buffer input stream
BufferedWriter Bw=null; Character Buffer output stream
try{
File F = new file ("F:\\ha.txt");
Fr =new FileReader (f); Read the file F
File s =new file ("F:\\haha.txt"); Copy the generated file name
FW =new FileWriter (s); Write to S.
BR =new BufferedReader (FR); Buffer Storage FR Content
BW = new BufferedWriter (FW); Contents of buffer Memory write FW
Char c [] =new char[(int) (F.length ())]; The length of the character C is the length of the F file
int Len=br.read (c); Define an intermediate variable to accept C
Bw.writer (C,0,len);
System.out.print (New String (C,0,len)); Need to be aware of type conversions
}catch (FileNotFoundException e) {
E.printstacktrace ();
}catch (IOException e) {
E.printstacktrace ();
}finally{
try{
Br.close ();
Bw.close ();
}catch (IOException e) {
E.printstacktrace ();
}
}
}
Java IO buffer Copy file