// 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 dk.vajhoej.record.RecordException;
import dk.vajhoej.record.StructReader;
import dk.vajhoej.record.StructWriter;

public class RW {
    public static void main(String[] args) throws RecordException {
        Data o1 = new Data(1, 2, 3, "ABC");
        StructWriter sw = new StructWriter();
        sw.write(o1);
        byte[] ba = sw.getBytes();
        for(byte b1 : ba) {
            System.out.printf(" %02X" , b1);
        }
        System.out.println();
        StructReader sr = new StructReader(ba);
        Data o2 = sr.read(Data.class);
        System.out.println(o2.getBf1() + " " + o2.getBf2() + " " + o2.getIv() + " " + o2.getSv());
    }
}
