List of usage examples for com.google.common.io ByteSource copyTo
public long copyTo(ByteSink sink) throws IOException
From source file:microsoft.exchange.webservices.data.core.EwsServiceXmlWriter.java
/** * Writes the base64-encoded element value. * * @param source the source containing bytes to be written * @throws IOException signals that an I/O exception has occurred *//*from w w w . ja va 2s .c o m*/ public void writeBase64ElementValue(ByteSource source) throws IOException { ByteSink sink = base64().encodingSink(new CharSink() { @Override public Writer openStream() throws IOException { return new BufferedWriter(new Writer() { @Override public void write(char[] cbuf, int off, int len) throws IOException { try { xmlWriter.writeCharacters(cbuf, off, len); } catch (XMLStreamException e) { throw new IOException("Error writing XML", e); } } @Override public void flush() { } @Override public void close() { } }); } }); source.copyTo(sink); }