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
()
| 346 | |
| 347 | |
| 348 | public boolean isEmpty() throws IOException { |
| 349 | Optional<Long> lengthIfKnown = lengthIfKnown(); |
| 350 | if (lengthIfKnown.isPresent() && lengthIfKnown.get() == 0L) { |
| 351 | return true; |
| 352 | } |
| 353 | Closer closer = Closer.create(); |
| 354 | try { |
| 355 | Reader reader = closer.register(openStream()); |
| 356 | return reader.read() == -1; |
| 357 | } catch (Throwable e) { |
| 358 | throw closer.rethrow(e); |
| 359 | } finally { |
| 360 | closer.close(); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Concatenates multiple {@link CharSource} instances into a single source. Streams returned from |
nothing calls this directly
no test coverage detected