MCPcopy Index your code
hub / github.com/antlr/codebuff / size

Method size

output/java_guava/1.4.17/ByteSource.java:207–230  ·  view source on GitHub ↗

Returns the size of this source in bytes, even if doing so requires opening and traversing an entire stream. To avoid a potentially expensive operation, see #sizeIfKnown. The default implementation calls #sizeIfKnown and returns the value if present. If absent, it will fall back

()

Source from the content-addressed store, hash-verified

205
206
207 public long size() throws IOException {
208 Optional<Long> sizeIfKnown = sizeIfKnown();
209 if (sizeIfKnown.isPresent()) {
210 return sizeIfKnown.get();
211 }
212 Closer closer = Closer.create();
213 try {
214 InputStream in = closer.register(openStream());
215 return countBySkipping(in);
216 } catch (IOException e) {
217 // skip may not be supported... at any rate, try reading
218 } finally {
219 closer.close();
220 }
221 closer = Closer.create();
222 try {
223 InputStream in = closer.register(openStream());
224 return ByteStreams.exhaust(in);
225 } catch (Throwable e) {
226 throw closer.rethrow(e);
227 } finally {
228 closer.close();
229 }
230 }
231
232 /**
233 * Counts the bytes in the given input stream using skip if possible. Returns SKIP_FAILED if the

Callers

nothing calls this directly

Calls 10

sizeIfKnownMethod · 0.95
createMethod · 0.95
registerMethod · 0.95
openStreamMethod · 0.95
countBySkippingMethod · 0.95
closeMethod · 0.95
exhaustMethod · 0.95
rethrowMethod · 0.95
getMethod · 0.65
isPresentMethod · 0.45

Tested by

no test coverage detected