posted 24 years ago
I don't know what constraints you're talking about. If memory is an issue, you should realize that the StringBuffer and byte[] will already take up a large amount of memory, roughly equal to that used by the String. (More specifically, the StringBuffer will require at least as much memory as the String, and the byte[] will take at least half as much as the String, depending on the character encoding used. So it's possible that creating the String and then the StringBuffer on top of it will require too much memory at once for your system to handle. If this is the case, you can avoid the String by replacing it with:
<code><pre> Reader reader = new InputStreamReader(new ByteArrayInputStream(byteArray), "UTF-8");</pre></code>
You can then create a loop to read characters from the reader and append them to your StringBuffer.
"I'm not back." - Bill Harding, Twister