ByteArray.java revision 3fa3e56afc259ce982ca4f8b51be7378b7e2021e
1package com.mot.dm.dbtool;
2
3public class ByteArray {
4  byte[] bytes = new byte[0];
5  public ByteArray() {
6  }
7
8  public void addByte(byte b) throws Exception {
9    byte[] arr = {
10        b};
11    addBytes(arr);
12  }
13
14  public void addBytes(byte[] b) throws Exception {
15    int count = 0;
16    byte[] newBytes = new byte[bytes.length + b.length];
17    for (int i = 0; i < bytes.length; i++) {
18      newBytes[count++] = bytes[i];
19    }
20    for (int i = 0; i < b.length; i++) {
21      newBytes[count++] = b[i];
22    }
23    bytes = newBytes;
24  }
25
26  public byte[] getBytes() throws Exception {
27    return bytes;
28  }
29
30  public int length() throws Exception {
31    return bytes.length;
32  }
33
34}
35