Java 8 BufferedOutputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 BufferedOutputStream class.

This code example shows how to use the following methods:flush, close
 
    private int generateTestList(String path) {
        int testCount = 0;
        try { 
            File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
            testCount = FsUtils.writeLayoutTestListRecursively(
                    bos, path, false); // Don't ignore results
            bos.flush();
            bos.close();
       } catch (Exception e) {
           Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());
       } 
       return testCount;
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:close
 
    protected AbstractFilePersistenceResource(final ModelNode model, final AbstractConfigurationPersister persister) throws ConfigurationPersistenceException {
        marshalled = new ExposedByteArrayOutputStream(1024 * 8);
        try { 
            try { 
                BufferedOutputStream output = new BufferedOutputStream(marshalled);
                persister.marshallAsXml(model, output);
                output.close();
                marshalled.close();
            } finally { 
                IoUtils.safeClose(marshalled);
            } 
        } catch (Exception e) {
            throw MESSAGES.failedToMarshalConfiguration(e);
        } 
    } 
 
    @Override 
    public void commit() { 
        if (marshalled == null) {
8
CodeRank
This code example shows how to use the following methods:
    @Override 
    public void start() { 
        final File file = new File(path);
        try { 
            final BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            final OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
            try { 
                System.out.println("--- writing");
                writer.write("Test\n");
            } finally { 
                try { 
                    writer.close();
                    System.out.println("--- written");
                } catch (Exception ignore) {
                } 
            } 
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        } 
8
CodeRank
This code example shows how to use the following methods:
    public Bitmap saveDataToCacheAndReturnData(Bitmap data, Object cacheKey) throws CacheSavingException {
        BufferedOutputStream out = null;
 
        try { 
            File cacheFile = getCacheFile(cacheKey);
            out = new BufferedOutputStream(new FileOutputStream(cacheFile));
 
            boolean didCompress = data.compress(compressFormat, quality, out);
            if (!didCompress) {
                throw new CacheSavingException(String.format("Could not compress bitmap for path: %s", getCacheFile(cacheKey).getAbsolutePath()));
            } 
 
            return data;
        } catch (IOException e) {
            throw new CacheSavingException(e);
        } finally { 
            IOUtils.closeQuietly(out);
        } 
    } 
 

8
CodeRank
This code example shows how to use the following methods:close
 
    static ExposedByteArrayOutputStream marshalXml(final AbstractConfigurationPersister persister, final ModelNode model) throws ConfigurationPersistenceException {
        ExposedByteArrayOutputStream marshalled = new ExposedByteArrayOutputStream(1024 * 8);
        try { 
            try { 
                BufferedOutputStream output = new BufferedOutputStream(marshalled);
                persister.marshallAsXml(model, output);
                output.close();
                marshalled.close();
            } finally { 
                IoUtils.safeClose(marshalled);
            } 
        } catch (Exception e) {
            throw MESSAGES.failedToMarshalConfiguration(e);
        } 
        return marshalled;
    } 
 
    static void copyFile(final File file, final File backup) throws IOException {
        final InputStream in = new BufferedInputStream(new FileInputStream(file));
8
CodeRank
This code example shows how to use the following methods:
	} 
 
	public void flush () { 
		OutputStream out = null;
		try { 
			out = new BufferedOutputStream(file.write(false));
			properties.store(out, null);
		} catch (Exception ex) {
			throw new GdxRuntimeException("Error writing preferences: " + file, ex);
		} finally { 
			StreamUtils.closeQuietly(out);
		} 
	} 
 
	public void remove (String key) {
		properties.remove(key);
	} 
} 
8
CodeRank
This code example shows how to use the following methods:flush, close
        File file = resourceLoader.find( directory, filename );
        if ( file == null ) {
            file = resourceLoader.createFile(directory, filename);
        } 
         
        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
        try { 
            XStreamPersister xp = xpf.createXMLPersister();
            initXStreamPersister(xp, gs);
            xp.save( service, out );
             
            out.flush();
        } 
        finally { 
            out.close();
        } 
    } 
     
    /** 
     * Hook for subclasses to configure the xstream. 
8
CodeRank
This code example shows how to use the following methods:close
            public void onClick(View v) {
                Bitmap b = mTextureView.getBitmap(800, 800);
                BufferedOutputStream out = null;
                try { 
                    File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
                    out = new BufferedOutputStream(new FileOutputStream(dump));
                    b.compress(Bitmap.CompressFormat.PNG, 100, out);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } finally { 
                    if (out != null) try {
                        out.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } 
                } 
            } 
        }); 
 
        Button button = new Button(this);
8
CodeRank
This code example shows how to use the following methods:flush, close
            @Override 
            public void run() { 
                if(diskCacheEnabled) {
                    BufferedOutputStream ostream = null;
                    try { 
                        ostream = new BufferedOutputStream(new FileOutputStream(new File(diskCachePath, getCacheKey(url))), 2*1024);
                        bitmap.compress(CompressFormat.PNG, 100, ostream);
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } finally { 
                        try { 
                            if(ostream != null) {
                                ostream.flush();
                                ostream.close();
                            } 
                        } catch (IOException e) {}
                    } 
                } 
            } 
        }); 
8
CodeRank
This code example shows how to use the following methods:
	 */ 
	public static int copy(File in, File out) throws IOException {
		Assert.notNull(in, "No input File specified");
		Assert.notNull(out, "No output File specified");
		return copy(new BufferedInputStream(new FileInputStream(in)),
			new BufferedOutputStream(new FileOutputStream(out)));
	} 
 
	/** 
	 * Copy the contents of the given byte array to the given output File. 
	 * @param in the byte array to copy from 
	 * @param out the file to copy to 
	 * @throws IOException in case of I/O errors 
	 */ 
	public static void copy(byte[] in, File out) throws IOException {
		Assert.notNull(in, "No input byte array specified");
		Assert.notNull(out, "No output File specified");
		ByteArrayInputStream inStream = new ByteArrayInputStream(in);
		OutputStream outStream = new BufferedOutputStream(new FileOutputStream(out));
		copy(inStream, outStream);
8
CodeRank

Related Java 8 BufferedOutputStream Questions & Answers:

See Code Examples for Java 8 BufferedOutputStream Methods: