Returns whether the source has zero chars. The default implementation returns true if #lengthIfKnown returns zero, falling back to opening a stream and checking for EOF if the length is not known. Note that, in cases where lengthIfKnown returns zero, it is possible that ch
()
| 332 | * @since 15.0 |
| 333 | */ |
| 334 | public boolean isEmpty() throws IOException { |
| 335 | Optional<Long> lengthIfKnown = lengthIfKnown(); |
| 336 | if (lengthIfKnown.isPresent() && lengthIfKnown.get() == 0L) { |
| 337 | return true; |
| 338 | } |
| 339 | Closer closer = Closer.create(); |
| 340 | try { |
| 341 | Reader reader = closer.register(openStream()); |
| 342 | return reader.read() == -1; |
| 343 | } catch (Throwable e) { |
| 344 | throw closer.rethrow(e); |
| 345 | } finally { |
| 346 | closer.close(); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /** |
| 351 | * Concatenates multiple {@link CharSource} instances into a single source. Streams returned from |
nothing calls this directly
no test coverage detected