Java examples for java.io:OutputStream
write Short to FileOutputStream
import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main{ private static final ByteOrder BYTE_ORDER_LE = ByteOrder.LITTLE_ENDIAN; public static void writeShort(FileOutputStream bos, short someShort) throws IOException { byte[] bytes = ByteBuffer.allocate(Short.SIZE / Byte.SIZE) .order(BYTE_ORDER_LE).putShort(someShort).array(); bos.write(bytes);//from w w w . j a va 2s .c om } }