android/guava/src/com/google/common/io/CharSource.java
public boolean isEmpty() throws IOException {
    Optional<Long> lengthIfKnown = lengthIfKnown();
    if (lengthIfKnown.isPresent()) {
      return lengthIfKnown.get() == 0L;
    }
    Closer closer = Closer.create();
    try {
      Reader reader = closer.register(openStream());
      return reader.read() == -1;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
public boolean isEmpty() throws IOException {
    Optional<Long> lengthIfKnown = lengthIfKnown();
    if (lengthIfKnown.isPresent()) {
      return lengthIfKnown.get() == 0L;
    }
    Closer closer = Closer.create();
    try {
      Reader reader = closer.register(openStream());
      return reader.read() == -1;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
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 {@code lengthIfKnown} returns zero, it is <i>possible</i> that
chars are actually available for reading. This means that a source may return {@code true} from
{@code isEmpty()} despite having readable content.

@throws IOException if an I/O error occurs
@since 15.0