Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; public class Main { private static int finishBlock(int code, ByteArrayOutputStream sink, byte[] src, int begin, int end) throws IOException { sink.write(code); if (begin > -1) sink.write(src, begin, (end - begin) + 1); return (byte) 0x01; } }