Example usage for com.google.common.io ByteSource toString

List of usage examples for com.google.common.io ByteSource toString

Introduction

In this page you can find the example usage for com.google.common.io ByteSource toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:be.fror.password.vault.core.VaultFormat.java

public static Vault read(ByteSource source) throws IOException, UnsupportedFormatException {
    VaultFormat[] formats = { Vault1Format.INSTANCE };
    try (PushbackInputStream in = new PushbackInputStream(source.openStream())) {
        for (VaultFormat format : formats) {
            if (format.accept(in)) {
                return format.read(in);
            }//from   w  ww . j  a  v  a  2  s .  c  o  m
        }
    }
    throw new UnsupportedFormatException(source.toString());
}

From source file:com.opengamma.strata.collect.io.UnicodeBom.java

/**
 * Converts a {@code ByteSource} to a {@code CharSource}.
 * <p>/*from   w  w w  .ja va 2s  .  c  om*/
 * This ensures that any Unicode byte order marker is used correctly.
 * The default encoding is UTF-8 if no BOM is found.
 * 
 * @param byteSource  the byte source
 * @return the char source, that uses the BOM to determine the encoding
 */
public static CharSource toCharSource(ByteSource byteSource) {
    return new CharSource() {

        @Override
        public ByteSource asByteSource(Charset charset) {
            return byteSource;
        }

        @Override
        public Reader openStream() throws IOException {
            return toReader(byteSource.openStream());
        }

        @Override
        public String toString() {
            return "UnicodeBom.toCharSource(" + byteSource.toString() + ")";
        }
    };
}

From source file:at.ac.univie.isc.asio.d2rq.LoadD2rqModel.java

/**
 * Resolving relative IRIs may require two parse passes, first to determine the embedded base URI,
 * then a second pass, using the found base URI.
 *
 * @param source raw turtle content// ww  w .  j  av a 2s .  c  o m
 * @return parsed model
 */
public Model parse(final ByteSource source) {
    try {
        final Model model = doParse(source);
        validator.assertNoUndefinedTerms(model, D2RQException.CONFIG_UNKNOWN_PROPERTY,
                D2RQException.CONFIG_UNKNOWN_CLASS);
        return model;
    } catch (IOException | JenaException | AtlasException | IllegalArgumentException e) {
        throw new RdfParseError(source.toString(), unwrap(e));
    }
}