@Override public InputStream openAsInputStream( File fileName ) throws IOException { return delegate.openAsInputStream( fileName ); }
@Override public InputStream openAsInputStream( File fileName ) throws IOException { return fs.openAsInputStream( fileName ); }
@Override public void addToArchive( Path archiveDestination, DiagnosticsReporterProgress progress ) throws IOException { long size = fs.getFileSize( source ); InputStream in = fs.openAsInputStream( source ); // Track progress of the file reading, source might be a very large file try ( ProgressAwareInputStream inStream = new ProgressAwareInputStream( in, size, progress::percentChanged ) ) { Files.copy( inStream, archiveDestination ); } }
@Override public InputStream openAsInputStream( File fileName ) throws IOException { return chooseFileSystem( fileName ).openAsInputStream( fileName ); }
@Override public InputStream openAsInputStream( File fileName ) throws IOException { adversary.injectFailure( FileNotFoundException.class, SecurityException.class ); return new AdversarialInputStream( delegate.openAsInputStream( fileName ), adversary ); }
try ( InputStream stream = fsa.openAsInputStream( file ) )
private void assertFormatSpecifierAndHeadersOnly( Map<String,byte[]> headers, FileSystemAbstraction fs, File file ) throws IOException { assertTrue( fs.fileExists( file ) ); try ( InputStream stream = fs.openAsInputStream( file ) ) { // format specifier int read; int size = 16; byte[] readEntry = new byte[size]; byte[] allZeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; read = stream.read( readEntry ); assertEquals( size, read ); assertArrayEquals( allZeros, readEntry ); read = stream.read( readEntry ); assertEquals( size, read ); assertArrayEquals( new byte[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, readEntry ); for ( int i = 0; i < headers.size(); i++ ) { read = stream.read( readEntry ); assertEquals( size, read ); assertArrayEquals( allZeros, readEntry ); read = stream.read( readEntry ); assertEquals( size, read ); headers.containsValue( readEntry ); } assertEquals( -1, stream.read() ); } }
pagedFileB.close(); InputStream inputStream = fs.openAsInputStream( fileB ); assertThat( "first page first byte", inputStream.read(), is( 63 ) ); for ( int i = 0; i < filePageSizeB - 1; i++ )
InputStream inputStream = fs.openAsInputStream( file( "a" ) ); for ( int i = 1; i <= 100; i++ )
@ParameterizedTest @ValueSource( ints = {0, 1} ) void swappingOutMustWritePageToFile( int noChannelStriping ) throws Exception { getFs().create( getFile() ).close(); byte[] expected = new byte[] { 1, 2, 3, 4 }; long page = createPage( expected ); PageSwapperFactory factory = createSwapperFactory(); PageSwapper swapper = createSwapper( factory, getFile(), 4, null, false, bool( noChannelStriping ) ); swapper.write( 0, page ); InputStream stream = getFs().openAsInputStream( getFile() ); byte[] actual = new byte[expected.length]; assertThat( stream.read( actual ), is( actual.length ) ); assertThat( actual, byteArray( expected ) ); }
try ( DataInputStream stream = new DataInputStream( fs.openAsInputStream( file( "a" ) ) ) )
try ( InputStream inputStream = fs.openAsInputStream( file2 ) )
swapper.write( 1, page ); InputStream stream = getFs().openAsInputStream( getFile() ); byte[] actual = new byte[(int) getFs().getFileSize( getFile() )];
InputStream read( FileSystemAbstraction fs ) throws IOException { InputStream source = fs.openAsInputStream( profileFile ); try { return new GZIPInputStream( source ); } catch ( IOException e ) { IOUtils.closeAllSilently( source ); throw new IOException( "Exception when building decompressor.", e ); } }
@Override public void addToArchive( Path archiveDestination, DiagnosticsReporterProgress progress ) throws IOException { long size = fs.getFileSize( source ); InputStream in = fs.openAsInputStream( source ); // Track progress of the file reading, source might be a very large file try ( ProgressAwareInputStream inStream = new ProgressAwareInputStream( in, size, progress::percentChanged ) ) { Files.copy( inStream, archiveDestination ); } }