// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.FileOutputStream;
import java.io.IOException;

import dk.vajhoej.record.Endian;
import dk.vajhoej.record.FieldType;
import dk.vajhoej.record.RecordException;
import dk.vajhoej.record.Struct;
import dk.vajhoej.record.StructField;
import dk.vajhoej.record.StructWriter;

public class Gen2X {
    @Struct(endianess=Endian.LITTLE)
    public static class Data {
        @StructField(n=0,type=FieldType.INT1)
        public byte b;
        @StructField(n=1,type=FieldType.INT2)
        public short s;
    }
    public static void main(String[] args) throws RecordException, IOException {
        Data o = new Data();
        o.b = 0x41;
        o.s = 0x4243;
        StructWriter sw = new StructWriter();
        sw.write(o);
        FileOutputStream fos = new FileOutputStream("/Work/z2x.txt");
        fos.write(sw.getBytes());
        fos.close();
    }
}
