yangxu998 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

A FilterInputStream variant that doesn't delegate skip() to skip() #593

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a useful wrapper similar to FilterInputStream, that can 
programmatically choose whether to delegate skip() or call the 
InputStream.skip() default implementation (which reads and discards the data).

Use cases include (but aren't limited to) DigestInputStream -- basically any 
InputStream wrapper intended to siphon off the data in-flight while another 
main code flow reads from it.

Original issue reported on code.google.com by tv@duh.org on 5 Apr 2011 at 6:03

Attachments:

GoogleCodeExporter commented 9 years ago
This seems reasonable enough, though we can always use more evidence of its 
broad applicability. 

Original comment by kevinb@google.com on 13 Jul 2011 at 7:39

GoogleCodeExporter commented 9 years ago
This is somewhat like an abstraction of the intended base functionality of e.g. 
DigestInputStream (which doesn't have this behavior; it won't digest over what 
is skipped).

However, there's a bug in the posted version, because the implementations of 
InputStream.skip() that I've seen use a static buffer for the reads, as opposed 
to an instance buffer. This will cause issues with CapturingInputStream in 
issue 594, so I've attached an updated version.

As for whether it belongs in guava, I'm ambivalent - it just happens to be a 
class I've used a lot, and this (plus the CapturingInputStream layer) works 
much more cleanly than TeeInputStream in Apache Commons IO.

Original comment by tv@duh.org on 13 Jul 2011 at 7:46

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 10 Dec 2011 at 4:04

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 16 Feb 2012 at 7:17

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 30 May 2012 at 7:43

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 22 Jun 2012 at 6:16

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:18

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09