import java.io.IOException; import java.util.ArrayList; import java.util.List; public class IntegerTest { public static Byte[] encode(int value) { List result = new ArrayList<>(); for (int i = 0; i < value; i++) { result.add((byte) 0xFF); } result.add((byte) 0x00); return result.toArray(new Byte[result.size()]); } public static void main(String[] args) throws IOException { int number = Integer.valueOf(args[0]); Byte[] objects = encode(number); byte[] bytes = new byte[objects.length]; for (int i = 0; i < bytes.length; i++) { bytes[i] = objects[i]; } System.out.write(bytes); } }