MCPcopy Create free account
hub / github.com/M66B/FairEmail / copy

Method copy

app/src/main/java/androidx/room/FileUtil.java:47–67  ·  view source on GitHub ↗

Copies data from the input channel to the output file channel. @param input the input channel to copy. @param output the output channel to copy. @throws IOException if there is an I/O error.

(@NonNull ReadableByteChannel input, @NonNull FileChannel output)

Source from the content-addressed store, hash-verified

45 * @throws IOException if there is an I/O error.
46 */
47 @SuppressLint("LambdaLast")
48 public static void copy(@NonNull ReadableByteChannel input, @NonNull FileChannel output)
49 throws IOException {
50 try {
51 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
52 output.transferFrom(input, 0, Long.MAX_VALUE);
53 } else {
54 InputStream inputStream = Channels.newInputStream(input);
55 OutputStream outputStream = Channels.newOutputStream(output);
56 int length;
57 byte[] buffer = new byte[1024 * 4];
58 while ((length = inputStream.read(buffer)) > 0) {
59 outputStream.write(buffer, 0, length);
60 }
61 }
62 output.force(false);
63 } finally {
64 input.close();
65 output.close();
66 }
67 }
68
69 private FileUtil() {
70 }

Callers 1

copyDatabaseFileMethod · 0.95

Calls 3

readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected