Used to create a directory if it does not exist. This will throw an unsafe IOException if the directory cannot be created. Only use this when you think mkdirs() must be successful. @param dir the directory to create if it does not exist @return the same directory as the parameter
(@NonNull File dir)
| 108 | * @return the same directory as the parameter |
| 109 | */ |
| 110 | @NonNull |
| 111 | public static File mkdirsOrThrow(@NonNull File dir) { |
| 112 | Objects.requireNonNull(dir, "dir == null"); |
| 113 | if (!dir.exists() && !dir.mkdirs()) { |
| 114 | unsafeThrow(new IOException("Failed to create directory: " + dir.getAbsolutePath())); |
| 115 | } |
| 116 | return dir; |
| 117 | } |
| 118 | |
| 119 | public static AssertionError unsafeThrow(@NonNull Throwable t) { |
| 120 | Objects.requireNonNull(t, "t == null"); |
no test coverage detected