Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?ISO-8859-1?Q?Sven_K=F6hler?= Newsgroups: comp.lang.java.programmer Subject: Re: StringBuilder for byte[] Date: Fri, 18 Jan 2013 18:08:13 +0100 Lines: 28 Message-ID: References: <7ff63461-89b5-4196-8902-ead245eb6945@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.dfncis.de PBPbHrw5FFQ7TgEEo8WASgzm3w626TZOUTSbwrP30r/EeHZW+wijEbH5AskgDG User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130113 Thunderbird/17.0.2 In-Reply-To: <7ff63461-89b5-4196-8902-ead245eb6945@googlegroups.com> Xref: csiph.com comp.lang.java.programmer:21527 Am 18.01.2013 17:54, schrieb Lew: > Sven Köhler wrote: >> Roedy Green: >>> It would be a fairly simple task to write a StringBuilder or FastCat >>> that worked with byte[]. I wonder if such a beast exists already, or >>> if there would be much use for it. >> >> ByteArrayOutputStream exists. Its write() method would be the equivalent >> of StringBuilder.append(). > > Actually, not quite. The former needs a Writer to handle encoding. Oh I see. You interpreted the question completely different. I was assuming, that the input was bytes, not characters. But anyway: wouldn't ByteArrayOutputStream + OutputStreamWriter be exactly the right thing if the input was characters? > A better choice would be > http://docs.oracle.com/javase/7/docs/api/java/io/CharArrayWriter.html It works with char[] internally. The question was about something that works with byte[] internally, I believe. Not sure, what that is good for though. Regards, Sven