@Override public void setLength(long newLength) throws IOException { raos.setLength(newLength); }
/** * Closes the current RandomAccessOutputStream to the zip file. * * @throws IOException if an error occurred */ private void closeWrite() throws IOException { if(raos!=null) { try { raos.close(); } finally { raos = null; } } }
public synchronized long getOffset() throws IOException { // Add the buffered byte count return raos.getOffset() + count; }
raos.close(); assert 100 == raos.getOffset(); assert 100 == raos.getLength(); assert 100 == tempFile.getSize(); raos.seek(0); assert 0 == raos.getOffset(); assert 100 == raos.getOffset(); assert 100 == raos.getLength(); assert 100 == tempFile.getSize(); raos.seek(50); assert 50 == raos.getOffset(); assert 150 == raos.getOffset(); assert 150 == raos.getLength(); assert 150 == tempFile.getSize(); raos.setLength(200); assert 200 == raos.getLength(); assert 200 == tempFile.getSize(); assert 150 == raos.getOffset(); raos.setLength(100); assert 100 == raos.getOffset(); assert 100 == raos.getLength();
RandomAccessOutputStream raos = (RandomAccessOutputStream)out; long save = raos.getOffset(); raos.seek(entry.getEntryInfo().headerOffset + 14); raos.write(ZipLong.getBytes(entry.getCrc(), zipBuffer.longBuffer)); raos.write(ZipLong.getBytes(entry.getCompressedSize(), zipBuffer.longBuffer)); raos.write(ZipLong.getBytes(entry.getSize(), zipBuffer.longBuffer)); raos.seek(save);
int nbEntries = entries.size(); long cdLength = 0; // Length of central directory long cdOffset = raos.getOffset(); // Offset of central directory for(int i=0; i<nbEntries; i++) { tempZe = entries.elementAt(i); tempEntryInfo.centralHeaderOffset = raos.getOffset(); tempEntryInfo.centralHeaderLen = raos.getOffset() - tempEntryInfo.centralHeaderOffset; raos.setLength(raos.getOffset());
/** * Validates that FileMonitor properly reports {@link FileMonitor#SIZE_ATTRIBUTE} changes when a file's size changes. * * @throws IOException should not normally happen */ @Test public void testSizeAttribute() throws IOException { setUp(SIZE_ATTRIBUTE); RandomAccessOutputStream raos = file.getRandomAccessOutputStream(); try { raos.setLength(10); assert hasAttributeChanged(SIZE_ATTRIBUTE); raos.setLength(0); } finally { if(raos!=null) raos.close(); } }
raos.seek(entryInfo.headerOffset+10); raos.write(ZipLong.getBytes(entry.getDosTime(), zipBuffer.longBuffer)); raos.seek(entryInfo.centralHeaderOffset+4); ZipOutputStream.writeVersionMadeBy(entry, raos, zipBuffer); raos.seek(entryInfo.centralHeaderOffset+12); raos.write(ZipLong.getBytes(entry.getDosTime(), zipBuffer.longBuffer)); raos.seek(entryInfo.centralHeaderOffset+38); raos.write(ZipLong.getBytes(entry.getExternalAttributes(), zipBuffer.longBuffer));
public void seek(long offset) throws IOException { raos.seek(offset); }
/** * Flushes the internal buffer. * * @throws IOException if an error occurs */ private void flushBuffer() throws IOException { if (count > 0) { raos.write(buffer, 0, count); count = 0; } }
public long getLength() throws IOException { return raos.getLength(); }
@Override public void flush() throws IOException { raos.flush(); }
public synchronized void seek(long offset) throws IOException { // Flush any buffered bytes before seeking, otherwise buffered bytes would be written at the wrong offset flush(); raos.seek(offset); }
@Override public void write(int b) throws IOException { raos.write(b); }
public synchronized long getLength() throws IOException { // Anticipate if the file is to be expanded by the bytes awaiting in the buffer return Math.max(raos.getLength(), getOffset()); }
/** * Flushes this buffered output stream. This forces any buffered * output bytes to be written out to the underlying output stream. * * @throws IOException if an I/O error occurs. */ @Override public synchronized void flush() throws IOException { flushBuffer(); raos.flush(); }
@Override public synchronized void setLength(long newLength) throws IOException { // Flush before changing the file's length, otherwise the behavior of setLength() would be modified, especially // when truncating the file flush(); raos.setLength(newLength); }