Java Utililty Methods List Concatenate

List of utility methods to do List Concatenate

Description

The list of methods to do List Concatenate are organized into topic(s).

Method

byte[]concatenateFileContent(List fileContents)
concatenate File Content
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);
...
int[]ConcatenateInt(List arrays)
Concatenate all the arrays in the list into a vector.
int size = 0;
for (int i = 0; i < arrays.size(); i++) {
    size += arrays.get(i).length;
int[] all = new int[size];
int idx = 0;
for (int i = 0; i < arrays.size(); i++) {
    int[] v = arrays.get(i);
...
StringconcatenateList(List values)
Concatenates a bunch of header values, seperating them with a comma.
StringBuffer buf = new StringBuffer();
for (int i = 0, size = values.size(); i < size; ++i) {
    buf.append(((String) values.get(i)).replaceAll("\n", "").trim());
    if (i != (size - 1)) {
        buf.append(",");
return buf.toString();
...
StringconcatenateList(List list, String separator)
Concatenates the list of Objects using the provided separator
if (list == null || list.isEmpty()) {
    return ""; 
StringBuilder result = new StringBuilder();
for (int i = 0; i < list.size() - 1; i++) {
    result.append(list.get(i) + separator);
result.append(list.get(list.size() - 1));
...
StringconcatenateListOfStrings(List list, String separator)
concatenate List Of Strings
StringBuffer buff = new StringBuffer();
for (String s : list) {
    buff.append(s).append(separator);
return buff.toString();
ListconcatenateLists(List... lists)
concatenate Lists
int len = 0;
for (List l : lists) {
    len += l.size();
List<String> result = new ArrayList<String>(len);
for (List l : lists) {
    for (Object o : l) {
        if (!(o instanceof String)) {
...
StringconcatenateParameters(List parameters)
concatenate Parameters
StringBuilder str = new StringBuilder();
boolean first = true;
for (String parameter : parameters) {
    if (first)
        first = false;
    else
        str.append(" ");
    str.append(parameter);
...
StringconcatenateStrings(List strings, String separator)
Concatenate the Strings in the List, putting the separator between each but not after the last.
String result = "";
if (strings != null && !strings.isEmpty()) {
    StringBuilder sb = new StringBuilder();
    for (String s : strings) {
        sb.append(s).append(separator);
    result = sb.toString();
    result = result.substring(0, result.length() - separator.length());
...
ListconcatenateUniqueLists(List first, List second)
Return a new List with no duplicated values.
List concatenation = new ArrayList(first.size() + second.size());
concatenation.addAll(first);
for (Object element : second) {
    if (!concatenation.contains(element)) {
        concatenation.add(element);
return concatenation;
...
StringconcatGenericList(List list, String delimiter)
Concatenate a list of objects into a single string.
StringBuilder ret = new StringBuilder();
boolean first = true;
for (Object s : list) {
    if (!first) {
        ret.append(delimiter);
    ret.append("" + s);
    first = false;
...