文档地址 http://tool.oschina.net/apidocs/apidoc?api=jdk-zh
void Test(){
try {
FileInputStream fis = new FileInputStream("/users/yifei/desktop/assets/js.txt");
FileOutputStream fos = new FileOutputStream("/users/yifei/desktop/assets/copy.txt");
InputStreamReader isr = new InputStreamReader(fis,"GBK");
OutputStreamWriter osw = new OutputStreamWriter(fos,"GBK");
int n = 0;
char[] cbuf =new char[1000];
while((n=isr.read(cbuf))!=-1 ) { //读 isr文件的东西 放在定义的空字符数组中
String s = new String(cbuf,0 ,n); //把读出的东西放在 字符串s中
}
osw.write(cbuf);
osw.flush();// 释放流
fis.close(); //关闭流 先打开的后关闭
fos.close();
isr.close();
osw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}