标签:stream input buffer sys put static iter stat fileinput
package demo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
public class Demo04{
public static void main(String[] args) throws IOException{
File fw = new File("E:\\tt.txt");
File fr = new File("F:\\PB学习\\pb.txt");
Demo04.FileWriter(fr, fw);
}
public static void FileWriter(File in,File ot) throws IOException{
if(!in.exists()){
in.getParentFile().mkdirs();
in.createNewFile();
}
if(!ot.exists()){
ot.getParentFile().mkdirs();
ot.createNewFile();
}
InputStreamReader isr=new InputStreamReader(new FileInputStream(in));
OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream(ot),"utf-8");
BufferedReader br = new BufferedReader(isr);
BufferedWriter bw = new BufferedWriter(osw);
char[] buffer = new char[1024];
int c;
while ((c = br.read(buffer,0,1024)) != -1) {
bw.write(buffer,0,c);
}
br.close();
bw.close();
System.out.println("OK");
}
}
标签:stream input buffer sys put static iter stat fileinput
原文地址:http://www.cnblogs.com/wumianjing/p/6814105.html