public static void combine(List<String> fileNames, String outputName) throws IOException {
    FileOutputStream fos = new FileOutputStream(outputName);

    GrowQueue_I8 buffer = new GrowQueue_I8();

    for (String s : fileNames) {
      File f = new File(s);
      FileInputStream fis = new FileInputStream(f);

      long length = f.length();
      buffer.resize((int) length);

      // write out header
      fos.write(255);
      fos.write(255);
      fos.write(255);
      fos.write((byte) (length >> 24));
      fos.write((byte) (length >> 16));
      fos.write((byte) (length >> 8));
      fos.write((byte) (length));

      fis.read(buffer.data, 0, (int) length);
      fos.write(buffer.data, 0, (int) length);
    }
  }
  public static boolean readNext(DataInputStream fis, GrowQueue_I8 output) throws IOException {
    int r;
    if ((r = fis.read()) != 0xFF || (r = fis.read()) != 0xFF || (r = fis.read()) != 0xFF)
      if (r == -1) return false;
      else throw new IllegalArgumentException("Bad header byte: " + r);

    int length =
        ((fis.read() & 0xFF) << 24)
            | ((fis.read() & 0xFF) << 16)
            | ((fis.read() & 0xFF) << 8)
            | (fis.read() & 0xFF);

    output.resize(length);
    fis.read(output.data, 0, length);

    return true;
  }