Code example for BufferedOutputStream

Methods: flush

0
        } 
    } 
 
    private static void writeFile(File file, Writer writer) throws IOException {
        final FileOutputStream fos = new FileOutputStream(file);
        final BufferedOutputStream bos = new BufferedOutputStream(fos);
        try { 
            writer.write(bos);
            bos.flush();
        } finally { 
            FileUtils.sync(fos);
            IoUtils.closeQuietly(bos);
        } 
    } 
 
    private static IOException rethrowAsIoException(Throwable t) throws IOException {
        if (t instanceof IOException) {
            throw (IOException) t;
        } else { 
            throw new IOException(t.getMessage(), t);
        }