package Test0717;import java.io.*;import static net.mindview.util.Print.*;public class TestCopy implements Runnable
{
Object o=new Object(); static String str="E:\\java";
public void run() 
{
File f=new File(str);
TestCopy.rmdir(f);



}
public static void rmdir(File path)
{

  if(!path.isDirectory())
{
print("这不是一个文件夹!");
return;

}
File[] file=path.listFiles();
for(int i=0;i<file.length;i++)
{
File f=file[i];
//print(f.getName());
if(f.isDirectory())
{

File filed=new File("back\\"+f.getParent().substring(str.length())+"\\"+f.getName());
filed.mkdir();
TestCopy.rmdir(f);
}else
{
//print();
copy(f.getParent().substring(str.length()),f);

}

}

}
void creatDir()
{

}
public synchronized static void copy(String s,File fi)
{
File f=new File("back");
if(f.exists())
{
f.delete();
}else
{
f.mkdir();
}
//print(s);
File temp=new File("back\\"+s+"\\"+fi.getName());
//print(fi.getName());
try {
temp.createNewFile();

} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
FileInputStream fis=new FileInputStream(fi);
FileOutputStream fos=new FileOutputStream(temp);
BufferedInputStream bis=new BufferedInputStream(fis);
BufferedOutputStream bos=new BufferedOutputStream(fos);
int i;
while((i=bis.read())!=-1)
{
bos.write(i);
}
bis.close();
bos.close();
fis.close();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}
public static void main(String args[])
{
TestCopy tc=new TestCopy();
Thread t1=new Thread(tc);
Thread t2=new Thread(tc);
t1.start();
t2.start();


}}