ByteBuffer bb = ByteBuffer.wrap(bytes, 0, length);
try (FileChannel fc = FileChannel.open(path, options, NO_ATTRIBUTES)) {
fc.write(bb);
+
+ writePosition += length;
+ if(TRACE_PERF) {
+ long duration = System.nanoTime()-start;
+ double ds = 1e-9*duration;
+ System.err.println("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
+ }
+ return result;
+ } catch (Throwable t) {
+ throw new IOException("An error occured file saving bytes for file " + path.toAbsolutePath().toString(), t);
}
-
- writePosition += length;
- if(TRACE_PERF) {
- long duration = System.nanoTime()-start;
- double ds = 1e-9*duration;
- System.err.println("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
- }
- return result;
}
public synchronized byte[] readBytes(int offset, int length) throws IOException {