Here you can find the source of writeByte(WritableByteChannel channel, byte value)
public static void writeByte(WritableByteChannel channel, byte value) throws IOException
//package com.java2s; /**// w ww. j a v a 2 s . c o m * This class is part of JCodec ( www.jcodec.org ) This software is distributed * under FreeBSD License * * @author The JCodec project * */ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.WritableByteChannel; public class Main { public static void writeByte(WritableByteChannel channel, byte value) throws IOException { channel.write((ByteBuffer) ByteBuffer.allocate(1).put(value).flip()); } public static void write(ByteBuffer to, ByteBuffer from) { if (from.hasArray()) { to.put(from.array(), from.arrayOffset() + from.position(), Math.min(to.remaining(), from.remaining())); } else { to.put(toArrayL(from, to.remaining())); } } public static byte[] toArrayL(ByteBuffer buffer, int count) { byte[] result = new byte[Math.min(buffer.remaining(), count)]; buffer.duplicate().get(result); return result; } public static ByteBuffer duplicate(ByteBuffer bb) { ByteBuffer out = ByteBuffer.allocate(bb.remaining()); out.put(bb.duplicate()); out.flip(); return out; } }