List of usage examples for com.google.common.io ByteSource isEmpty
public boolean isEmpty() throws IOException
From source file:ratpack.jackson.configuration.internal.JacksonConfigurationFactory.java
@Override public <T extends Configuration> T build(Class<T> configurationClass, ConfigurationSource configurationSource) throws ConfigurationException { ObjectNode node;//from w ww .j a v a 2s . c o m ByteSource byteSource = configurationSource.getByteSource(); try { if (byteSource.isEmpty()) { node = JsonNodeFactory.instance.objectNode(); } else { try (InputStream inputStream = configurationSource.getByteSource().openBufferedStream()) { YAMLParser yamlParser = yamlFactory.createParser(inputStream); node = objectMapper.readTree(yamlParser); } } return build(configurationClass, node); } catch (IOException ex) { throw new ConfigurationException("Failed to load configuration", ex); } }
From source file:org.jasig.cas.extension.clearpass.EncryptedMapDecorator.java
/** * Read the contents of the source into a byte array. * @param source the byte array source//from w ww .ja v a2s. c om * @return the byte[] read from the source or null */ private byte[] consumeByteSourceOrNull(final ByteSource source) { try { if (source == null || source.isEmpty()) { return null; } return source.read(); } catch (final IOException e) { logger.warn("Could not consume the byte array source", e); return null; } }