/** Stores the element returned by an iterator to a file given by a pathname. * * @param i an iterator whose output will be written to {@code filename}. * @param filename a filename. */ public static void storeBytes(final ByteIterator i, final CharSequence filename) throws IOException { storeBytes(i, new File(filename.toString())); } /** A wrapper that exhibits the content of a data input stream as a type-specific iterator. */
/** Stores an array to a file given by a pathname. * * @param array an array whose elements will be written to {@code filename}. * @param filename a filename. */ public static void storeBytes(final byte array[], final CharSequence filename) throws IOException { storeBytes(array, new File(filename.toString())); } /** Loads elements from a given data input, storing them in a given big-array fragment.
/** Stores an array fragment to a file given by a pathname. * * @param array an array whose elements will be written to {@code filename}. * @param offset the index of the first element of {@code array} to be written. * @param length the number of elements of {@code array} to be written. * @param filename a filename. */ public static void storeBytes(final byte array[], final int offset, final int length, final CharSequence filename) throws IOException { storeBytes(array, offset, length, new File(filename.toString())); } /** Stores an array to a file given by a {@link File} object.
/** Stores a big-array fragment to a file given by a pathname. * * @param array a big array whose elements will be written to {@code filename}. * @param offset the index of the first element of {@code array} to be written. * @param length the number of elements of {@code array} to be written. * @param filename a filename. */ public static void storeBytes(final byte array[][], final long offset, final long length, final CharSequence filename) throws IOException { storeBytes(array, offset, length, new File(filename.toString())); } /** Stores an array to a file given by a {@link File} object.
/** Stores a big array to a file given by a pathname. * * @param array a big array whose elements will be written to {@code filename}. * @param filename a filename. */ public static void storeBytes(final byte array[][], final CharSequence filename) throws IOException { storeBytes(array, new File(filename.toString())); } /** Stores the element returned by an iterator to a given data output.
private void write( final int b ) { if ( avail == 0 ) { final int oldLength = buffer.length; try { buffer = ByteArrays.grow( buffer, buffer.length + 1 ); } catch( OutOfMemoryError e ) { outOfMemoryError = true; try { // We try at all costs to avoid out-of-memory errors: we dump the buffer, try to allocate a slightly larger array and reload it. File temp = File.createTempFile( ByteArrayPostingList.class.getSimpleName(), "dump" ); temp.deleteOnExit(); BinIO.storeBytes( buffer, temp ); buffer = null; buffer = new byte[ oldLength + POSTINGS_EMERGENCY_INCREMENT ]; BinIO.loadBytes( temp, buffer ); temp.delete(); } catch ( IOException f ) { throw new RuntimeException( f ); } } avail += buffer.length - oldLength; } avail--; buffer[ pos++ ] = (byte)b; }
private void write( final int b ) { if ( avail == 0 ) { final int oldLength = buffer.length; try { buffer = ByteArrays.grow( buffer, buffer.length + 1 ); } catch( OutOfMemoryError e ) { outOfMemoryError = true; try { // We try at all costs to avoid out-of-memory errors: we dump the buffer, try to allocate a slightly larger array and reload it. File temp = File.createTempFile( ByteArrayPostingList.class.getSimpleName(), "dump" ); temp.deleteOnExit(); BinIO.storeBytes( buffer, temp ); buffer = null; buffer = new byte[ oldLength + POSTINGS_EMERGENCY_INCREMENT ]; BinIO.loadBytes( temp, buffer ); temp.delete(); } catch ( IOException f ) { throw new RuntimeException( f ); } } avail += buffer.length - oldLength; } avail--; buffer[ pos++ ] = (byte)b; }
private void write( final int b ) { if ( avail == 0 ) { final int oldLength = buffer.length; try { buffer = ByteArrays.grow( buffer, buffer.length + 1 ); } catch( OutOfMemoryError e ) { outOfMemoryError = true; try { // We try at all costs to avoid out-of-memory errors: we dump the buffer, try to allocate a slightly larger array and reload it. File temp = File.createTempFile( ByteArrayPostingList.class.getSimpleName(), "dump" ); temp.deleteOnExit(); BinIO.storeBytes( buffer, temp ); buffer = null; buffer = new byte[ oldLength + POSTINGS_EMERGENCY_INCREMENT ]; BinIO.loadBytes( temp, buffer ); temp.delete(); } catch ( IOException f ) { throw new RuntimeException( f ); } } avail += buffer.length - oldLength; } avail--; buffer[ pos++ ] = (byte)b; }
private void write( final int b ) { if ( avail == 0 ) { final int oldLength = buffer.length; try { buffer = ByteArrays.grow( buffer, buffer.length + 1 ); } catch( OutOfMemoryError e ) { outOfMemoryError = true; try { // We try at all costs to avoid out-of-memory errors: we dump the buffer, try to allocate a slightly larger array and reload it. File temp = File.createTempFile( ByteArrayPostingList.class.getSimpleName(), "dump" ); temp.deleteOnExit(); BinIO.storeBytes( buffer, temp ); buffer = null; buffer = new byte[ oldLength + POSTINGS_EMERGENCY_INCREMENT ]; BinIO.loadBytes( temp, buffer ); temp.delete(); } catch ( IOException f ) { throw new RuntimeException( f ); } } avail += buffer.length - oldLength; } avail--; buffer[ pos++ ] = (byte)b; }