@Override public OutputStream newOutputStream( final Path path, final OpenOption... options ) throws IllegalArgumentException, UnsupportedOperationException, IOException, SecurityException { return Files.newOutputStream( path, options ); }
/** * @throws IllegalArgumentException * @throws IOException * @throws UnsupportedOperationException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newBufferedWriter(java.nio.file.Path, java.nio.charset.Charset, java.nio.file.OpenOption...)">Original JavaDoc</a> */ public static BufferedWriter newBufferedWriter( final Path path, final Charset cs, final OpenOption... options ) throws IllegalArgumentException, IOException, UnsupportedOperationException, SecurityException { checkNotNull( "path", path ); checkNotNull( "cs", cs ); return new BufferedWriter( new OutputStreamWriter( newOutputStream( path, options ), cs ) ); }
final OutputStream out = newOutputStream( path, options );
public static Path write( final Path path, final byte[] bytes, final OpenOption... options ) throws IOException, UnsupportedOperationException, SecurityException { checkNotNull( "path", path ); checkNotNull( "bytes", bytes ); final OutputStream out = newOutputStream( path, options ); int len = bytes.length; int rem = len; try { while ( rem > 0 ) { int n = ( rem <= BUFFER_SIZE ) ? rem : BUFFER_SIZE; out.write( bytes, ( len - rem ), n ); rem -= n; } return path; } catch ( java.io.IOException e ) { throw new IOException( e ); } finally { try { out.close(); } catch ( java.io.IOException e ) { throw new IOException( e ); } } }
final OutputStream out = newOutputStream( target, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE );