Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[错误修复] FileUtils.java #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,19 @@ public static boolean isFile(final File file) {
*/
public static List<File> getFileList(String path, FileFilter filter, boolean isGreater, long targetSize) {
List<File> list = FileUtils.getFileListByDirPath(path, filter);
//进行过滤文件大小
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
File f = (File) iterator.next();
for (int i = 0; i < list.size(); i++) {
File f = list.get(i);
if (f.isFile()) {
//获取当前文件大小
long size = FileUtils.getFileLength(f);
if (isGreater) {
//当前想要留下大于指定大小的文件,所以过滤掉小于指定大小的文件
if (size < targetSize) {
iterator.remove();
list.remove(i);
i--; // 删除后我们调整索引
}
} else {
//当前想要留下小于指定大小的文件,所以过滤掉大于指定大小的文件
if (size > targetSize) {
iterator.remove();
list.remove(i);
i--; // 删除后我们调整索引
}
}
}
Expand Down