Esempio n. 1
0
 /** {@inheritDoc} */
 @Override
 public void write(final byte[] b, final int off, final int len) throws IOException {
   final ByteBuffer input = ByteBuffer.wrap(b, off, len);
   final int required = encoder.outputSize(len - off);
   if (output == null || output.capacity() < required) {
     output = CharBuffer.allocate(required);
   } else {
     output.clear();
   }
   encoder.encode(input, output);
   output.flip();
   writer.write(output.toString());
   writer.flush();
 }
Esempio n. 2
0
 /** {@inheritDoc} */
 @Override
 public void close() throws IOException {
   if (output == null) {
     output = CharBuffer.allocate(8);
   } else {
     output.clear();
   }
   encoder.finalize(output);
   output.flip();
   writer.write(output.toString());
   writer.flush();
   writer.close();
 }