0X00
获取桌面文件夹所有文件,把文件包装成自己写的filemod类,拆分出文件后缀。按照后缀把文件分类后copy到对应的文件夹中,如果copy成功则将桌面文件删除处理。暂未实现桌面文件夹内的文件遍历。
0x01
File 接口
public interface file { //get and setter public String getFileName(); public String getFilePath(); public String getFileSuffix(); public long getFileSize(); public void setFileName(String fname); public void setFilePath(String filePath); public void setFileSize(int size); public void setFileSuffix(String suffix); }
实现类 FileMod
import java.io.File; public class FileMod implements file{ private String fileName = null; private String filePath=null; private long fileSize=-1; private String fileSuffix=null; private File f=null; private boolean fisnull=true; private String toPath=""; public FileMod(File f){ this.f=f; this.fisnull=false; } public FileMod(){ } public String getFileName() { if(!fisnull){ return f.getName(); }else{ return this.fileName; } } public String getFilePath() { if(!fisnull){ return f.getAbsolutePath(); }else{ return this.filePath; } } public String getFileSuffix() { if(!fisnull){ String name=f.getName(); int dindex= name.lastIndexOf("."); return name.substring(dindex+1,name.length()); }else{ return this.getFileSuffix(); } } public long getFileSize() {