问题;
能不能按照后缀名过滤器的思想做一个文件大小过滤器,只接收文件长度大于指定大小的文件
但思路混乱只做到以下地步,自己把自己绕了进去求指点
package io;
import java.io.File;
interface IFileCapcity
{
boolean capcityacccept(File f,long capcity);
}
class Filecapcity implements IFileCapcity
{
private long capcity;
private File f;
public boolean capcityacccept(File f,long capcity)
{
long filecapcity=0l;
File[] fs=f.listFiles();
for (File index : fs)
{
filecapcity= index.length();
}
return filecapcity>capcity;
}
}
public class FileCapcityFilter
{
public static void main(String[] args)
{
File f = new File("G:/file");
String[]sgv =listAll(f,1024);
for (String str : sgv) {
System.out.println(str);
}
}
public static String[] listAll(File f,long capcity)
{
File[]fs= f.listFiles();
String[] s=new String[fs.length];
for(int index=0 ;index<fs.length;index++ )
{
while(fs[index].length()>capcity)
{
for(int l=0;l<index;l++)
{
s[l]=fs[index].getName();
}
}
}
return s;
}
}
|