mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +02:00
Add FileUtils.maybeDeleteFileOrThrow(File)
This commit is contained in:
parent
affdcb0557
commit
a70ae7ab8e
4 changed files with 15 additions and 25 deletions
|
@ -196,4 +196,15 @@ public final class FileUtils {
|
|||
throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void maybeDeleteFileOrThrow(File file) throws IOException {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean successfullyDeleted = file.delete();
|
||||
if (!successfullyDeleted) {
|
||||
throw new IOException("Could not delete file " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue