(@NonNull File file, @NonNull byte[] data)
| 146 | } |
| 147 | |
| 148 | public static void writeFile(@NonNull File file, @NonNull byte[] data) throws IOException { |
| 149 | Objects.requireNonNull(file, "file == null"); |
| 150 | Objects.requireNonNull(data, "data == null"); |
| 151 | if (!file.exists()) { |
| 152 | File parent = file.getParentFile(); |
| 153 | if (parent != null && !parent.exists()) { |
| 154 | mkdirsOrThrow(parent); |
| 155 | } |
| 156 | if (!file.createNewFile()) { |
| 157 | throw new IOException("Failed to create file: " + file.getAbsolutePath()); |
| 158 | } |
| 159 | } |
| 160 | try (OutputStream os = new FileOutputStream(file)) { |
| 161 | os.write(data); |
| 162 | os.flush(); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | @NonNull |
| 167 | public static byte[] calculateFileMd5(@NonNull InputStream is) throws IOException { |
nothing calls this directly
no test coverage detected