MCPcopy
hub / github.com/google/guava / isEmpty

Method isEmpty

guava/src/com/google/common/io/CharSource.java:416–430  ·  view source on GitHub ↗

Returns whether the source has zero chars. The default implementation first checks {@link #lengthIfKnown}, returning true if it's known to be zero and false if it's known to be non-zero. If the length is not known, it falls back to opening a stream and checking for EOF. <p>Note that, in cases where

()

Source from the content-addressed store, hash-verified

414 * @since 15.0
415 */
416 public boolean isEmpty() throws IOException {
417 Optional<Long> lengthIfKnown = lengthIfKnown();
418 if (lengthIfKnown.isPresent()) {
419 return lengthIfKnown.get() == 0L;
420 }
421 Closer closer = Closer.create();
422 try {
423 Reader reader = closer.register(openStream());
424 return reader.read() == -1;
425 } catch (Throwable e) {
426 throw closer.rethrow(e);
427 } finally {
428 closer.close();
429 }
430 }
431
432 /**
433 * Concatenates multiple {@link CharSource} instances into a single source. Streams returned from

Callers 1

testConcatMethod · 0.95

Calls 9

lengthIfKnownMethod · 0.95
createMethod · 0.95
registerMethod · 0.95
openStreamMethod · 0.95
rethrowMethod · 0.95
closeMethod · 0.95
getMethod · 0.65
isPresentMethod · 0.45
readMethod · 0.45

Tested by 1

testConcatMethod · 0.76