Copy up to byteLimit bytes from the input stream to the output stream. @param os Destination stream @param is Input stream @param byteLimit Maximum number of bytes to copy @param buffer IO buffer to use @return Number of bytes actually copied
(RandomAccessFile os, InputStream is, int byteLimit, byte[] buffer)
| 313 | * @return Number of bytes actually copied |
| 314 | */ |
| 315 | static int copyBytes(RandomAccessFile os, InputStream is, int byteLimit, byte[] buffer) |
| 316 | throws IOException { |
| 317 | // Yes, this method is exactly the same as the above, just with a different type for `os'. |
| 318 | int bytesCopied = 0; |
| 319 | int nrRead; |
| 320 | while (bytesCopied < byteLimit |
| 321 | && (nrRead = is.read(buffer, 0, Math.min(buffer.length, byteLimit - bytesCopied))) != -1) { |
| 322 | os.write(buffer, 0, nrRead); |
| 323 | bytesCopied += nrRead; |
| 324 | } |
| 325 | return bytesCopied; |
| 326 | } |
| 327 | |
| 328 | public static void fsyncAll(File fileName) throws IOException { |
| 329 | Stack<File> filesStack = new Stack<>(); |
no test coverage detected