Here you can find the source of concatLines(List
public static String concatLines(List<String> lines)
//package com.java2s; /*//from w w w . j a v a2s.c om * Copyright (C) 2014 Markus Junginger, greenrobot (http://greenrobot.de) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.List; public class Main { /** * Returns a concatenated string consisting of the given lines seperated by a new line character \n. The last line * does not have a \n at the end. */ public static String concatLines(List<String> lines) { StringBuilder builder = new StringBuilder(); int countMinus1 = lines.size() - 1; for (int i = 0; i < countMinus1; i++) { builder.append(lines.get(i)).append('\n'); } if (!lines.isEmpty()) { builder.append(lines.get(countMinus1)); } return builder.toString(); } }