Article View: borland.public.jbuilder.java.api
Article #777Re: Byte-Char Conversion
From: Owen Green
Date: Wed, 16 Oct 2002 15:44
Date: Wed, 16 Oct 2002 15:44
29 lines
2242 bytes
2242 bytes
"Owen Green" <owen@begonefoulmachine.kennulz.demon.co.uk> wrote in message news:3da9a473$1@newsgroups.borland.com... > Hi, > > Is there a standard idiom for situations where one wants to read both > byte and character data from the same stream? > > AFAICS, InputStreamReader is the only officially mandated method of > safely converting from one to the other*, but this will read more data > than it actually needs from the underlying stream, which isn't > desireable. > Looking at the guts of InputStreamReader, a solution may be to provide an intermediatary buffer that drip feeds the reader with an ultra-conservative number of bytes (say, ooh, one :). This will mean it has to refill and reconvert much more often though, which may knacker performance. Can't think of anything else though, short of creating a new String, byte by byte (!). (It also means that direct calls to read(char[]...) will break the contract of the reader, but this will all be internal) This seems to be straying dangerously near relying on an implementation detail though. Thoughts, comments and insults welcome. Owen
Technical Details
Message-ID:
<3dad8948$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!TELOCITY!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3da9a473$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,c3655063af01f787 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-10-16 09:00:01 PST From: "Owen Green" <owen@begonefoulmachine.kennulz.demon.co.uk> Newsgroups: borland.public.jbuilder.java.api References: <3da9a473$1@newsgroups.borland.com> Subject: Re: Byte-Char Conversion Date: Wed, 16 Oct 2002 16:44:16 +0100 Lines: 34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 62.253.133.165 Message-ID: <3dad8948$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1034783048 62.253.133.165 (16 Oct 2002 08:44:08 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!TELOCITY!news-out.spamkiller.net!propagator2-maxim!news-in.spamkiller.net!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail