Beispiel #1
0
 public static boolean buildEnvelope(int tag, String inputFileName, String outputFileName) {
   boolean retval = false;
   InputStream is = AqFileUtils.openFileInputStream(inputFileName);
   OutputStream os = AqFileUtils.openFileOutputStream(outputFileName, false);
   retval = buildEnvelope(tag, is, os);
   return retval;
 }
Beispiel #2
0
  public boolean getData(String outputFileName, boolean saveCRC) {
    // ^^FQB=entering Envelope.getData()
    AqLog.getInstance().debug("^^FQB:" + outputFileName);

    OutputStream os = null;

    /*
     **  Create an output file based on the name.
     */
    try {
      os = AqFileUtils.openFileOutputStream(outputFileName, false);

    } catch (Exception e) {
      //  The file may be corrupt.
      // ^^FQ3=File could not be extracted from download.  fileName:
      AqLog.getInstance().info("^^FQ3 " + outputFileName);
      return false;
    }

    boolean retval = false;
    if (null != os) {
      retval = getData(os);
      if (saveCRC) {
        ByteEncoder be = new ByteEncoder();
        int icrc = (int) (this.getEnvelopeCrc() & 0xffffffff);
        be.writeSignedInt(4, (icrc));
        byte[] bcrc = be.getContent();
        try {
          os.write(bcrc, 0, 4);
          os.flush();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      // ^^FQF=closed GF os:
      AqFileUtils.closeStream("^^FQF" + outputFileName, os);
    }
    return retval;
  }