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
()
| 148 | |
| 149 | |
| 150 | public boolean isEmpty() throws IOException { |
| 151 | Optional<Long> sizeIfKnown = sizeIfKnown(); |
| 152 | if (sizeIfKnown.isPresent() && sizeIfKnown.get() == 0L) { |
| 153 | return true; |
| 154 | } |
| 155 | Closer closer = Closer.create(); |
| 156 | try { |
| 157 | InputStream in = closer.register(openStream()); |
| 158 | return in.read() == -1; |
| 159 | } catch (Throwable e) { |
| 160 | throw closer.rethrow(e); |
| 161 | } finally { |
| 162 | closer.close(); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * 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