All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.clustering.OutputStreamAdapter Maven / Gradle / Ivy

There is a newer version: 0.27
Show newest version
package io.hyperfoil.clustering;

import java.io.OutputStream;

import io.netty.buffer.Unpooled;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.streams.WriteStream;

public class OutputStreamAdapter extends OutputStream {
   private final WriteStream stream;

   public OutputStreamAdapter(WriteStream stream) {
      this.stream = stream;
   }

   @Override
   public void write(byte[] b) {
      stream.write(Buffer.buffer(Unpooled.wrappedBuffer(b)));
   }

   @Override
   public void write(byte[] b, int off, int len) {
      stream.write(Buffer.buffer(Unpooled.wrappedBuffer(b, off, len)));
   }

   @Override
   public void close() {
      stream.end();
   }

   @Override
   public void write(int b) {
      Buffer buffer = Buffer.buffer(1);
      buffer.appendByte((byte) b);
      stream.write(buffer);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy