nyla.solutions.core.io.IOFileOperation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.core Show documentation
Show all versions of nyla.solutions.core Show documentation
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();
}
}