Java tutorial
import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; public class Main { public static void main(String[] args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos); int b = 87; bos.write(b); bos.flush(); byte[] bytes = baos.toByteArray(); System.out.println(bytes[0]); } }