/** * Updates the contents of the stream to the new * set of bytes. * Note - if this is property based, you'll still * need to update the size in the property yourself */ void updateContents(byte[] contents) throws IOException { OutputStream os = getOutputStream(); os.write(contents); os.close(); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (_closed) { throw new IOException("cannot perform requested operation on a closed stream"); } if (_limit > -1 && (size() + len) > _limit) { throw new IOException("tried to write too much data"); } if (_buffer != null) { _buffer.write(b, off, len); checkBufferSize(); } else { if (_stream == null) { _stream = new POIFSStream(_document.getFileSystem()); _stream_output = _stream.getOutputStream(); } _stream_output.write(b, off, len); _document_size += len; } }
/** * Writes the properties out into the given low-level stream */ public void write(POIFSStream stream) throws IOException { OutputStream os = stream.getOutputStream(); for(Property property : _properties) { if(property != null) { property.writeData(os); } } os.close(); // Update the start position if needed if(getStartBlock() != stream.getStartBlock()) { setStartBlock(stream.getStartBlock()); } }
try (OutputStream os = _stream.getOutputStream()) { length = IOUtils.copy(bis, os);
/** * Updates the contents of the stream to the new * set of bytes. * Note - if this is property based, you'll still * need to update the size in the property yourself */ void updateContents(byte[] contents) throws IOException { OutputStream os = getOutputStream(); os.write(contents); os.close(); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (_closed) { throw new IOException("cannot perform requested operation on a closed stream"); } if (_limit > -1 && (size() + len) > _limit) { throw new IOException("tried to write too much data"); } if (_buffer != null) { _buffer.write(b, off, len); checkBufferSize(); } else { if (_stream == null) { _stream = new POIFSStream(_document.getFileSystem()); _stream_output = _stream.getOutputStream(); } _stream_output.write(b, off, len); _document_size += len; } }
/** * Writes the properties out into the given low-level stream */ public void write(POIFSStream stream) throws IOException { OutputStream os = stream.getOutputStream(); for(Property property : _properties) { if(property != null) { property.writeData(os); } } os.close(); // Update the start position if needed if(getStartBlock() != stream.getStartBlock()) { setStartBlock(stream.getStartBlock()); } }
try (OutputStream os = _stream.getOutputStream()) { length = IOUtils.copy(bis, os);