Java Scanner Usage joinSqlStatements(Collection scripts)

Here you can find the source of joinSqlStatements(Collection scripts)

Description

join Sql Statements

License

Open Source License

Declaration

public static List<String> joinSqlStatements(Collection<String> scripts) 

Method Source Code

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

Related

  1. isInteger(String s)
  2. isNumeric(String str)
  3. isValueValid(String value, String pattern)
  4. isYes(String str)
  5. iterate(final String node)
  6. leerOpcion(String opciones, String msgUsr, String msgErr)
  7. leerTexto(String msgUsr)
  8. listify(String s, String prefix, String... ignorelist)
  9. listify(String s, String prefix, String... ignorelist)