/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static ByteIterator asByteIterator(final File file) throws IOException { return new ByteDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static CharIterator asCharIterator(final File file) throws IOException { return new CharDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static IntIterator asIntIterator(final File file) throws IOException { return new IntDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static LongIterator asLongIterator(final File file) throws IOException { return new LongDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static FloatIterator asFloatIterator(final File file) throws IOException { return new FloatDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Loads an object from a file given by a {@link File} object. * * @param file a file. * @return the object stored under the given file. * @see #storeObject(Object, File) */ public static Object loadObject(final File file) throws IOException, ClassNotFoundException { final ObjectInputStream ois = new ObjectInputStream(new FastBufferedInputStream(new FileInputStream(file))); final Object result = ois.readObject(); ois.close(); return result; } /** Loads an object from a file given by a pathname.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static DoubleIterator asDoubleIterator(final File file) throws IOException { return new DoubleDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static BooleanIterator asBooleanIterator(final File file) throws IOException { return new BooleanDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
/** Wraps a file given by a {@link File} object into an iterator. * * @param file a file. */ public static ShortIterator asShortIterator(final File file) throws IOException { return new ShortDataInputWrapper(new DataInputStream(new FastBufferedInputStream(new FileInputStream(file)))); } /** Wraps a file given by a pathname into an iterator.
public OfflineIterator<T, U> iterator() { try { dos.flush(); final DataInputStream dis = new DataInputStream( new FastBufferedInputStream( new FileInputStream( file ) ) ); return new OfflineIterator<T, U>( dis, serializer, store, size ); } catch ( IOException e ) { throw new RuntimeException( e ); } }
public OfflineIterator<T, U> iterator() { try { dos.flush(); final DataInputStream dis = new DataInputStream( new FastBufferedInputStream( new FileInputStream( file ) ) ); return new OfflineIterator<T, U>( dis, serializer, store, size ); } catch ( IOException e ) { throw new RuntimeException( e ); } }
static void fillArrayFromResource( final String resource, final int array[] ) throws IOException { final String resouceFullPath = "/it/unimi/dsi/io/" + resource; final InputStream ris = InputBitStream.class.getResourceAsStream( resouceFullPath ); if ( ris == null ) throw new IOException( "Cannot open resource " + resouceFullPath ); DataInputStream dis = new DataInputStream( new FastBufferedInputStream( ris ) ); BinIO.loadInts( dis, array, 0, array.length ); dis.close(); if ( ASSERTS ) { final int actualLength = IntIterators.unwrap( BinIO.asIntIterator( new DataInputStream( InputBitStream.class.getResourceAsStream( resouceFullPath ) ) ) ).length; assert array.length == actualLength : resource + " is long " + actualLength + " but we think it should rather be " + array.length; } }
@Override public OfflineIterator<T, U> iterator() { try { dos.flush(); final DataInputStream dis = new DataInputStream(new FastBufferedInputStream(new FileInputStream(file))); return new OfflineIterator<>(dis, serializer, store, size); } catch (final IOException e) { throw new RuntimeException(e); } }
@Override public FileLinesIterator listIterator(final int index) { try { return new FileLinesIterator(this, index, new FastBufferedInputStream(new FileInputStream(filename), bufferSize), charset.newDecoder(), ByteBuffer.wrap(new byte[byteBuffer.array().length]), CharBuffer.wrap(new char[charBuffer.array().length])); } catch (final FileNotFoundException e) { throw new RuntimeException(e); } }
public void run() { try { InputStream in = new FileInputStream( wikipediaXmlDump ); if ( bzipped ) in = new BZip2CompressorInputStream( in ); parser.parse( new InputSource( new InputStreamReader( new FastBufferedInputStream( in ), Charsets.UTF_8 ) ), handler ); readyDocumentsAndFactories.put( END ); } catch ( Exception e ) { throw new RuntimeException( e.getMessage(), e ); } } };
private FileLinesIterator(final String filename, final boolean zipped, final EnumSet<LineTerminator> terminators) { this.terminators = terminators; try { fbis = new FastBufferedInputStream(zipped ? new GZIPInputStream(new FileInputStream(filename)) : new FileInputStream(filename)); } catch (final IOException e) { throw new RuntimeException(e); } }
@Override public FileLinesIterator listIterator(final long index) { try { return new FileLinesIterator(this, index, new FastBufferedInputStream(new FileInputStream(filename), bufferSize), charset.newDecoder(), ByteBuffer.wrap(new byte[byteBuffer.array().length]), CharBuffer.wrap(new char[charBuffer.array().length])); } catch (final FileNotFoundException e) { throw new RuntimeException(e); } }
static void fillArrayFromResource(final String resource, final int array[]) throws IOException { final String resouceFullPath = "/it/unimi/dsi/io/" + resource; final InputStream ris = InputBitStream.class.getResourceAsStream(resouceFullPath); if (ris == null) throw new IOException("Cannot open resource " + resouceFullPath); DataInputStream dis = new DataInputStream(new FastBufferedInputStream(ris)); BinIO.loadInts(dis, array, 0, array.length); dis.close(); assert checkLength(resource, array, resouceFullPath); }
public Document nextDocument() throws IOException { if ( index == size ) return null; if ( index == firstDocument[ f + 1 ] ) { fbis.close(); fbis = new FastBufferedInputStream( new FileInputStream( file[ ++f ] ) ); } readDocument( index, f, fbis ); return document( index++ ); } };
public Document nextDocument() throws IOException { if ( index == size ) return null; if ( index == firstDocument[ f + 1 ] ) { fbis.close(); fbis = new FastBufferedInputStream( new FileInputStream( file[ ++f ] ) ); } readDocument( index, f, fbis ); return document( index++ ); } };