All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nyla.solutions.core.io.IOFileOperation Maven / Gradle / Ivy

Go to download

This Java API provides support for application utilities (application configuration, data encryption, debugger, text processing, and more).

The newest version!
package nyla.solutions.core.io;

import java.io.File;
import java.nio.file.Path;

/**
 * @author Gregory Green
 */
public class IOFileOperation
{
    private final File file;

    public IOFileOperation(File file)
    {
        if(file == null)
            throw new NullPointerException("file provided is null");
        this.file = file;
    }

    public void deleteDirectoryFiles()
    {
        if(!this.file.isDirectory())
            return;

        File[] files = this.file.listFiles();
        if(files == null)
            return;

        for (File nestedFile: files)
        {
            nestedFile.delete();
        }
    }

    /**
     *
     * @return the created parent
     */
    public File mkParentDir()
    {
        Path parent = this.file.toPath().getParent();
        parent.toFile().mkdir();
        return parent.toFile();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy