Guava ByteSink - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ByteSink class.

This code example shows how to use the following methods:openStream
    } 
 
    @Override 
    public void process(String outputName, ByteSource byteSource,
                        ByteSink byteSink, boolean closeAtFinish) throws IOException {
        process(outputName, byteSource.openStream(), byteSink.openStream(), closeAtFinish);
    } 
 
    @Override 
    public void process(String outputName, InputStream in, OutputStream out, boolean closeAtFinish) throws IOException {
 
        Reader reader = null;
        Writer writer = null;
 
        try { 
            reader = new InputStreamReader(in, charset);
            writer = new OutputStreamWriter(out, charset);
 
            MavenLogErrorReporter reporter = new MavenLogErrorReporter(outputName);
            new JavaScriptCompressor(reader, reporter).compress(writer, 0, true, true, false, false);
4
CodeRank
This code example shows how to use the following methods:openStream
    } 
 
    @Override 
    public void process(String outputName, ByteSource byteSource,
                        ByteSink byteSink, boolean closeAtFinish) throws IOException {
        process(outputName, byteSource.openStream(), byteSink.openStream(), closeAtFinish);
    } 
 
    @Override 
    public void process(String outputName, InputStream in, OutputStream out, boolean closeAtFinish) throws IOException {
 
        Reader reader = null;
        Writer writer = null;
 
        try { 
            reader = new InputStreamReader(in, charset);
            writer = new OutputStreamWriter(out, charset);
 
            CurrentResourceContext crc = (CurrentResourceContext) CurrentResourceContext.getInstance(FacesContext.getCurrentInstance());
 
4
CodeRank
This code example shows how to use the following methods:openStream
    } 
 
    @Override 
    public void process(String outputName, ByteSource byteSource,
                        ByteSink byteSink, boolean closeAtFinish) throws IOException {
        process(outputName, byteSource.openStream(), byteSink.openStream(), closeAtFinish);
    } 
 
    @Override 
    public void process(String outputName, InputStream in, OutputStream out, boolean closeAtFinish) throws IOException {
        Reader reader = null;
        Writer writer = null;
 
        try { 
            reader = new InputStreamReader(in, charset);
            writer = new OutputStreamWriter(out, charset);
 
            new CssCompressor(reader).compress(writer, 0);
        } finally { 
            try { 
4
CodeRank
This code example shows how to use the following methods:openStream
    } 
 
    @Override 
    public void process(String outputName, ByteSource byteSource,
                        ByteSink byteSink, boolean closeAtFinish) throws IOException {
        process(outputName, byteSource.openStream(), byteSink.openStream(), closeAtFinish);
    } 
 
    @Override 
    public void process(String outputName, InputStream in, OutputStream out, boolean closeAtFinish) throws IOException {
        try { 
            StreamUtils.copy(in, out);
        } finally { 
            try { 
                in.close();
            } catch (IOException e) {
                // Swallow 
            } 
            if (closeAtFinish) {
                try { 
4
CodeRank
This code example shows how to use the following methods:openStream
        try { 
            cipher = getCipher(Cipher.ENCRYPT_MODE, key);
        } catch (Throwable e) {
            throw new IOException("Failed to create cipher", e);
        } 
        return new CipherOutputStream(delegate.openStream(), cipher);
    } 
 
    public static Cipher getCipher(int mode, String password)
            throws InvalidKeySpecException, NoSuchAlgorithmException,
            NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
        // These parameters were used for encrypting lastlogin on old official Minecraft launchers 
        Random random = new Random(0x29482c2L);
        byte salt[] = new byte[8];
        random.nextBytes(salt);
        PBEParameterSpec paramSpec = new PBEParameterSpec(salt, 5);
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey key = factory.generateSecret(new PBEKeySpec(password.toCharArray()));
        Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
        cipher.init(mode, key, paramSpec);
4
CodeRank
This code example shows how to use the following methods:openStream
    } 
 
    @Override 
    public OutputStream openStream() throws IOException {
        dir.mkdirs();
        return delegate.openStream();
    } 
 
} 
4
CodeRank
See Code Examples for Guava ByteSink Methods: