Returns whether the source has zero bytes. The default implementation returns true if #sizeIfKnown returns zero, falling back to opening a stream and checking for EOF if the size is not known. Note that, in cases where sizeIfKnown returns zero, it is possible that bytes ar
()
| 136 | * @since 15.0 |
| 137 | */ |
| 138 | public boolean isEmpty() throws IOException { |
| 139 | Optional<Long> sizeIfKnown = sizeIfKnown(); |
| 140 | if (sizeIfKnown.isPresent() && sizeIfKnown.get() == 0L) { |
| 141 | return true; |
| 142 | } |
| 143 | Closer closer = Closer.create(); |
| 144 | try { |
| 145 | InputStream in = closer.register(openStream()); |
| 146 | return in.read() == -1; |
| 147 | } catch (Throwable e) { |
| 148 | throw closer.rethrow(e); |
| 149 | } finally { |
| 150 | closer.close(); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns the size of this source in bytes, if the size can be easily determined without actually |
nothing calls this directly
no test coverage detected