java糞?議窃貌windows荷恬狼由議xCopy
扮寂:2011-04-05
package com.iwindyforest.dir;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
public class FileSystem
{
private ArrayList<String> fileList = new ArrayList<String>();
public FileSystem(String path)
{
long a = System.currentTimeMillis();
this.listFiles(path);
this.print("TimeCost:" + (System.currentTimeMillis() - a) + " Millis");
this.xCopy(path, "C: \\temp");
}
private void print(String message)
{
System.out.println(message);
}
public void listFiles(String strPath)
{
File dir = new File(strPath);
if(dir != null && dir.exists())
{
if(dir.isDirectory())
{
File[] files;
try
{
files = dir.listFiles();
}
catch(SecurityException e)
{
files = null;
e.printStackTrace();
}
if(files == null)
{
return;
}
else
{
for(int i = 0; i < files.length; i++)
{
String strFileName = files[i].getAbsolutePath();
if(files[i].isDirectory())
{
this.print("D--:" + strFileName);
this.listFiles(files[i].getAbsolutePath());
}
else
{
this.print("F--:" + strFileName);
fileList.add(files[i].getAbsolutePath());
}
}
}
}
else
{
this.print("F--:" + dir.getAbsolutePath());
}
}
else
{
this.print("FileNotExist:" + dir.getAbsolutePath());
}
}
private boolean checkDir(File dir)
{
if(dir == null)
{
this.print("dirPath is null");
return false;
}
else if(!dir.exists())
{
this.print("dirPath: " + dir.getAbsolutePath() + " doesn''t exist.");
return false;
}
else if(!dir.isDirectory())
{
this.print("dirPath: " + dir.getAbsolutePath()
+ " is not a directory.");
return false;
}
else
{
return true;
}
}
/**
* 窃貌嚥windows荷恬狼由議xCopy?弓拷申唄屁倖坿朕村欺朕炎朕
|