生成的文件按序号01,02,03,04去排列,有需要的同学可以使用,希望可以帮到你
public static String generateName(File fil,final String fileName){
int count = fil.listFiles(new FileFilter(){
public boolean accept(File file){
if(file.getName().startsWith(fileName)){
return true;
}else{
return false;
}
}
}).length;
DecimalFormat df = new DecimalFormat("00");
String uniqueName = fileName + df.format(++count);
return uniqueName;
}
}