``` for ( byte b : byteArrayOutputStream.toByteArray() ) { writer.write( (char) b ); } ``` This loop is error-prone because a byte does not necessarily represent a char. If a multibyte character is encountered, the output will be mangled.
This loop is error-prone because a byte does not necessarily represent a char. If a multibyte character is encountered, the output will be mangled.