mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 02:39:42 +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