追加文件尾部
----------------------------------------------
复制文件夹
-----------------------------------
public void testPrintWrite() throws Exception{
FileWriter fw=new FileWriter("D:/text.txt",true);
BufferedWriter bw=new BUfferWriter(fw);
PrintWrite pw=new BufferedWriter(bw);
pw.println("测试添加1");
pw.println("测试添加2");
pw.close();
bw.close();
fw.close();
}
----------------------------------------------
复制文件夹
public void copyFolder(String oldPath,String newPath){
try{
(new File(newPath)).mkdirs();//如果不存在就创建
File a =new File(oldPath);
String[] file=a.list();
File temp=null;
for(int i=0;i<file.length;i++){
if(oldPath.endWith(File.separator)){
temp=new File(oldFile+file[i]);
}else{
temp=new File(oldFile+File.separator+file[i]);
}
if(temp.isFile()){
FileInputStream input=new FileInputStream(temp);
FileOutputStream output=new FileOutputStream(newPath+"/"+(temp.getName()).toString() );
byte[] b=new byte[1024*5];
int len;
while((len=input.read(b))!=-1){
output.write(b,0,len);
}
output.flush();
output.close();
input.close();
}
if(temp.isDirectory()){
copyFolder(oldPath+"/"+file[i],newPath+"/"+file[i]);
}
}
}catch(
){
}
}
-----------------------------------