MCPcopy Create free account
hub / github.com/cinit/TMoe / writeFile

Method writeFile

app/src/main/java/cc/ioctl/tmoe/util/IoUtils.java:148–164  ·  view source on GitHub ↗
(@NonNull File file, @NonNull byte[] data)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 1

mkdirsOrThrowMethod · 0.95

Tested by

no test coverage detected