Java List Concatenate concatenateFileContent(List fileContents)

Here you can find the source of concatenateFileContent(List fileContents)

Description

concatenate File Content

License

Open Source License

Parameter

Parameter Description
fileContents a parameter

Declaration

public static byte[] concatenateFileContent(List<byte[]> fileContents) 

Method Source Code

//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;
    }
}

Related

  1. concatenate(List xs)
  2. concatenate(List a, List b)
  3. concatenate(List contents, String separator)
  4. concatenate(List... lists)
  5. concatenate(String[] selectors, List lessExtends)
  6. ConcatenateInt(List arrays)
  7. concatenateList(List values)
  8. concatenateList(List list, String separator)
  9. concatenateListOfStrings(List list, String separator)