Java Code Examples for android.system.Os#write()
The following examples show how to use
android.system.Os#write() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUtils.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void run() { final FileDescriptor fd = getInternalFD(); try { int i = 0; while (i < data.length) { if (sink) { i += Os.read(fd, data, i, data.length - i); } else { i += Os.write(fd, data, i, data.length - i); } } } catch (IOException | ErrnoException e) { // Ignored } finally { if (sink) { SystemClock.sleep(TimeUnit.SECONDS.toMillis(1)); } IoUtils.closeQuietly(fd); } }
Example 2
Source File: FileBridge.java From container with GNU General Public License v3.0 | 6 votes |
/** * java.io always writes every byte it's asked to, or fails with an error. (That is, unlike * Unix it never just writes as many bytes as happens to be convenient.) */ public static void write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException { ArrayUtils.checkOffsetAndCount(bytes.length, byteOffset, byteCount); if (byteCount == 0) { return; } try { while (byteCount > 0) { int bytesWritten = Os.write(fd, bytes, byteOffset, byteCount); byteCount -= bytesWritten; byteOffset += bytesWritten; } } catch (ErrnoException errnoException) { throw new IOException(errnoException); } }