Re: What replaces StringBufferInputStream



"M.J. Dance" <mjdance@xxxxxxxxxxx> writes:

That seems to be the problem with this input stream <-> reader (and
output stream <-> writer, for that matter) dichotomy. Every(?) reader
has an uderlying input stream which, I imagine, wouldn't be a problem
to obtain.

Except, e.g., StringReader.

If you are communicating between processes, or even computers, then at
some point you'll represent your data as the lowest common
denominator: bytes, but working inside a single program, you can start
out with characters and keep it that way.

There is no way to meaningfully convert a generic Writer to an
OutputStream, and it's an implementation detail whether there is an
underlying OutputStream for a given Writer, so the Writer interface
can't meaningfully expose a method for giving out an OutputStream.

On the opposite end, you shouldn't blindly convert an InputStream
to a Reader without knowing that the bytes do represent characters
in the encoding you have chosen.

/L
--
Lasse Reichstein Nielsen - lrn@xxxxxxxxxx
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
.



Relevant Pages

  • Re: What replaces StringBufferInputStream
    ... You can create an OutputStream decorator which wraps ... Writer (or an InputStream which wraps a Reader) in just the same way as an ... OutputStreamWriter wraps an OutputStream. ...
    (comp.lang.java.programmer)
  • Re: [PATCH 3/3] ring-buffer: add design document
    ... This adds the design document for the ring buffer and also ... +head - where new reads happen in the ring buffer. ... +producer - the task that writes into the ring buffer (same as writer) ... +reader - same as consumer. ...
    (Linux-Kernel)
  • Re: [PATCH 3/3] ring-buffer: add design document
    ... This adds the design document for the ring buffer and also ... +head - where new reads happen in the ring buffer. ... +producer - the task that writes into the ring buffer (same as writer) ... +reader - same as consumer. ...
    (Linux-Kernel)
  • [PATCH v2 3/3] ring-buffer: add design document
    ... This adds the design document for the ring buffer and also ... +head - where new reads happen in the ring buffer. ... +producer - the task that writes into the ring buffer (same as writer) ... +reader - same as consumer. ...
    (Linux-Kernel)
  • [PATCH 3/3] ring-buffer: add design document
    ... This adds the design document for the ring buffer and also ... +head - where new reads happen in the ring buffer. ... +producer - the task that writes into the ring buffer (same as writer) ... +reader - same as consumer. ...
    (Linux-Kernel)