3 public class read_trace
{
4 public static void main(String
[] args
) {
18 if(filename
.equals("")) {
19 System
.out
.println("error: no filename specified");
24 FileInputStream file_input
= new FileInputStream (filename
);
25 BufferedInputStream buffered_input
= new BufferedInputStream(file_input
);
26 DataInputStream data_input
= new DataInputStream (buffered_input
);
33 timestamp
= data_input
.readInt();
34 id
= data_input
.readShort();
35 length
= data_input
.readByte();
37 byte[] buf
= new byte[length
];
38 data_input
.readFully(buf
, 0, length
);
41 ByteArrayInputStream eargs
= new ByteArrayInputStream(buf
);
42 DataInputStream eargs_data
= new DataInputStream (eargs
);
44 /* read arg 1 (short) */
45 short arg1
= eargs_data
.readShort();
47 /* read arg 2 (string) */
48 eargs_data
.mark(10000);
50 while(eargs_data
.readByte() != 0)
53 byte[] arg2
= new byte[strlen
];
54 eargs_data
.readFully(arg2
, 0, strlen
);
56 if(args
.length
>0 && args
[0].equals("-p"))
57 System
.out
.printf("timestamp %d id %d args=(short=%d string=\"%s\") %n", timestamp
, id
, arg1
, new String(arg2
));
61 catch(IOException e
) {
62 //System.out.println ("IO exception = " + e );
63 //e.printStackTrace();