Here you can find the source of concatenateFileContent(List
Parameter | Description |
---|---|
fileContents | a parameter |
public static byte[] concatenateFileContent(List<byte[]> fileContents)
//package com.java2s; /*//w w w . j a v a 2s .c o m * Copyright (c) 2013 IANA. All Rights Reserved. THE AUTHOR MAKES NO * REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE * AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import java.util.List; public class Main { /** * * @param fileContents * @return */ public static byte[] concatenateFileContent(List<byte[]> fileContents) { int length = 0; for (byte[] content : fileContents) { length += content.length; } byte[] mergedFileContents = new byte[length]; int destPos = 0; for (byte[] fileContent : fileContents) { System.arraycopy(fileContent, 0, mergedFileContents, destPos, fileContent.length); destPos += fileContent.length; } return mergedFileContents; } }