Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;

public class Main {
    private static boolean deleteFileWithExceptsInner(File file, String suffix, String[] exceptFileNames,
            AtomicBoolean excepted) {
        String fileName = file.getName().toLowerCase(Locale.US);
        if (canDeleteWithSuffixInner(fileName, suffix) && !equalsFileNamesInner(fileName, exceptFileNames)) {
            return file.delete();
        } else {
            if (excepted != null)
                excepted.set(true);
        }
        return true;
    }

    private static boolean canDeleteWithSuffixInner(String fileName, String suffix) {
        return suffix == null || suffix.length() <= 0 || fileName.endsWith(suffix);
    }

    private static boolean equalsFileNamesInner(String fileName, String[] exceptFileNames) {
        if (exceptFileNames != null) {
            for (String exceptName : exceptFileNames) {
                if (fileName.equals(exceptName))
                    return true;
            }
        }
        return false;
    }
}