Skip to content

Instantly share code, notes, and snippets.

@stepango
Created November 14, 2016 03:20
Show Gist options
  • Save stepango/fcded7beac2e1979cf57013c65a9f557 to your computer and use it in GitHub Desktop.
Save stepango/fcded7beac2e1979cf57013c65a9f557 to your computer and use it in GitHub Desktop.
Copy data from FileDescriptor to File in Kotlin, using okio
fun copy(fd: FileDescriptor, file: File) {
Okio.source(FileInputStream(fd)).use { source ->
Okio.buffer(Okio.sink(file)).use { buffer -> buffer.writeAll(source) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment