@Override public void flush() { if (isClosed()) throw new IllegalStateException("already closed"); try { RandomAccessFile raFile = new RandomAccessFile(getFullName(), "rw"); try { long len = getCapacity(); writeHeader(raFile, len, segmentSizeInBytes); raFile.seek(HEADER_OFFSET); byte bytes[] = new byte[segmentSizeInBytes]; int segs = getSegments(); for (int s = 0; s < segs; s++) { getBytes(s * segmentSizeInBytes, bytes, segmentSizeInBytes); raFile.write(bytes); } } finally { raFile.close(); } } catch (Exception ex) { throw new RuntimeException("Couldn't store bytes to " + toString(), ex); } }
int read = raFile.read(bytes); if (read <= 0) throw new IllegalStateException("segment " + s + " is empty? " + toString());
@Override public void flush() { if (isClosed()) throw new IllegalStateException("already closed"); try { RandomAccessFile raFile = new RandomAccessFile(getFullName(), "rw"); try { long len = getCapacity(); writeHeader(raFile, len, segmentSizeInBytes); raFile.seek(HEADER_OFFSET); byte bytes[] = new byte[segmentSizeInBytes]; int segs = getSegments(); for (int s = 0; s < segs; s++) { getBytes(s * segmentSizeInBytes, bytes, segmentSizeInBytes); raFile.write(bytes); } } finally { raFile.close(); } } catch (Exception ex) { throw new RuntimeException("Couldn't store bytes to " + toString(), ex); } }
@Override public void flush() { if (isClosed()) throw new IllegalStateException("already closed"); try { RandomAccessFile raFile = new RandomAccessFile(getFullName(), "rw"); try { long len = getCapacity(); writeHeader(raFile, len, segmentSizeInBytes); raFile.seek(HEADER_OFFSET); byte bytes[] = new byte[segmentSizeInBytes]; int segs = getSegments(); for (int s = 0; s < segs; s++) { getBytes(s * segmentSizeInBytes, bytes, segmentSizeInBytes); raFile.write(bytes); } } finally { raFile.close(); } } catch (Exception ex) { throw new RuntimeException("Couldn't store bytes to " + toString(), ex); } }
int read = raFile.read(bytes); if (read <= 0) throw new IllegalStateException("segment " + s + " is empty? " + toString());
int read = raFile.read(bytes); if (read <= 0) throw new IllegalStateException("segment " + s + " is empty? " + toString());
@Override public void flush() { if (isClosed()) throw new IllegalStateException("already closed"); try { RandomAccessFile raFile = new RandomAccessFile(getFullName(), "rw"); try { long len = getCapacity(); writeHeader(raFile, len, segmentSizeInBytes); raFile.seek(HEADER_OFFSET); byte bytes[] = new byte[segmentSizeInBytes]; int segs = getSegments(); for (int s = 0; s < segs; s++) { getBytes(s * segmentSizeInBytes, bytes, segmentSizeInBytes); raFile.write(bytes); } } finally { raFile.close(); } } catch (Exception ex) { throw new RuntimeException("Couldn't store bytes to " + toString(), ex); } }
throw new IllegalStateException("segment " + s + " is empty? " + toString());