0

私は2バイト配列を持っています。system.arraycopy を使用して連結しています。例外はスローされませんが、結果のストリームには 2 番目の配列データのみが表示されます

byte mainPdf[] = generatePDF(creditAppPDFurl, cifNumber,appRefId,pdfid1,appTransId);
byte supportingPdf[] = generateSupportingDocPDF();

byte[] destination = new byte[mainPdf.length + supportingPdf.length];
System.arraycopy(mainPdf, 0, destination, 0, mainPdf.length);
System.arraycopy(supportingPdf, 0, destination, mainPdf.length, supportingPdf.length);
pdfInputStreamData = new ByteArrayInputStream(destination);

pdfInputStreamData は、supportingPdf データのみを表示しています

4

2 に答える 2

2

あなたのコードは問題なく、エラーは別の場所にあります。特に、元の配列には期待する情報が含まれていない可能性があります。

次の簡単な例を試して、コードの配列連結部分が機能することを確認できます。

public static void main(String[] args) throws Exception {
    byte mainPdf[] = {1, 2, 3};
    byte supportingPdf[] = {4, 5, 6};

    byte[] destination = new byte[mainPdf.length + supportingPdf.length];
    System.arraycopy(mainPdf, 0, destination, 0, mainPdf.length);
    System.arraycopy(supportingPdf, 0, destination, mainPdf.length, supportingPdf.length);

    System.out.println(Arrays.toString(destination));
}

印刷し[1, 2, 3, 4, 5, 6]ます。

于 2013-06-10T16:11:16.450 に答える