public boolean isEmpty() throws IOException {
    Optional<Long> sizeIfKnown = sizeIfKnown();
    if (sizeIfKnown.isPresent()) {
      return sizeIfKnown.get() == 0L;
    }
    Closer closer = Closer.create();
    try {
      InputStream in = closer.register(openStream());
      return in.read() == -1;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
public boolean isEmpty() throws IOException {
    Optional<Long> sizeIfKnown = sizeIfKnown();
    if (sizeIfKnown.isPresent()) {
      return sizeIfKnown.get() == 0L;
    }
    Closer closer = Closer.create();
    try {
      InputStream in = closer.register(openStream());
      return in.read() == -1;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
public boolean isEmpty ( ) throws IOException { Optional < Long > sizeIfKnown = sizeIfKnown ( ) ; if ( sizeIfKnown . isPresent ( ) ) { return sizeIfKnown . get ( ) == 0L ; } Closer closer = Closer . create ( ) ; try { InputStream in = closer . register ( openStream ( ) ) ; return in . read ( ) == - 1 ; } catch ( Throwable e ) { throw closer . rethrow ( e ) ; } finally { closer . close ( ) ; } }
Returns whether the source has zero bytes. The default implementation first checks {@link
#sizeIfKnown}, returning true if it's known to be zero and false if it's known to be non-zero.
If the size is not known, it falls back to opening a stream and checking for EOF.

<p>Note that, in cases where {@code sizeIfKnown} returns zero, it is <i>possible</i> that bytes
are actually available for reading. (For example, some special files may return a size of 0
despite actually having content when read.) 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
Returns whether the source has zero bytes . The default implementation first checks { @link #sizeIfKnown } returning true if it s known to be zero and false if it s known to be non - zero . If the size is not known it falls back to opening a stream and checking for EOF .