@Override public InputStream newInputStream( final Path path, final OpenOption... options ) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException { return Files.newInputStream( path, options ); }
/** * @throws IllegalArgumentException * @throws NoSuchFileException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newBufferedReader(java.nio.file.Path, java.nio.charset.Charset)">Original JavaDoc</a> */ public static BufferedReader newBufferedReader( final Path path, final Charset cs ) throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException { checkNotNull( "path", path ); checkNotNull( "cs", cs ); return new BufferedReader( new InputStreamReader( newInputStream( path ), cs.newDecoder() ) ); }
public static byte[] readAllBytes( final Path path ) throws IOException, OutOfMemoryError, SecurityException { long size = size( path ); if ( size > (long) Integer.MAX_VALUE ) { throw new OutOfMemoryError( "Required array size too large" ); } final InputStream in = newInputStream( path ); final ByteArrayOutputStream buffer = new ByteArrayOutputStream( (int) size ); int read; byte[] data = new byte[ BUFFER_SIZE ]; try { while ( ( read = in.read( data, 0, data.length ) ) != -1 ) { buffer.write( data, 0, read ); } buffer.flush(); return buffer.toByteArray(); } catch ( java.io.IOException e ) { throw new IOException( e ); } finally { try { in.close(); } catch ( java.io.IOException e ) { throw new IOException( e ); } } }
public static long copy( final Path source, final OutputStream out ) throws IOException, SecurityException { checkNotNull( "source", source ); checkNotNull( "out", out ); final InputStream in = newInputStream( source ); try { return internalCopy( in, out ); } finally { try { in.close(); } catch ( java.io.IOException e ) { throw new IOException( e ); } } }