Here you can find the source of joinSqlStatements(Collection
public static List<String> joinSqlStatements(Collection<String> scripts)
//package com.java2s; /*/*from w ww . j ava2 s . c o m*/ * Copyright (c) Mirth Corporation. All rights reserved. * * http://www.mirthcorp.com * * The software in this package is published under the terms of the MPL license a copy of which has * been included with this distribution in the LICENSE.txt file. */ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Scanner; public class Main { public static List<String> joinSqlStatements(Collection<String> scripts) { List<String> scriptList = new ArrayList<String>(); for (String script : scripts) { script = script.trim(); StringBuilder sb = new StringBuilder(); boolean blankLine = false; Scanner scanner = new Scanner(script); while (scanner.hasNextLine()) { String temp = scanner.nextLine(); if (temp.trim().length() > 0) { sb.append(temp + " "); } else { blankLine = true; } if (blankLine || !scanner.hasNextLine()) { scriptList.add(sb.toString().trim()); blankLine = false; sb.delete(0, sb.length()); } } } return scriptList; } }