public static String[] processMutliLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter) {

        StringClauses parsed = SqlParser.parse(multiLineSQL, true, !stripComments);

        List<String> returnArray = new ArrayList<>();

        StringBuilder currentString = new StringBuilder();
        String previousPiece = null;
        boolean previousDelimiter = false;
        List<Object> parsedArray = Arrays.asList(parsed.toArray(true));
        for (Object piece : mergeTokens(parsedArray, endDelimiter)) {
            if (splitStatements && (piece instanceof String) && isDelimiter((String) piece, previousPiece, endDelimiter)) {
                String trimmedString = StringUtil.trimToNull(currentString.toString());
                if (trimmedString != null) {
                    returnArray.add(trimmedString);
                }
                currentString = new StringBuilder();
                previousDelimiter = true;
            } else {
                if (!previousDelimiter || (StringUtil.trimToNull((String) piece) != null)) { //don't include whitespace after a delimiter
                    if ((currentString.length() > 0) || (StringUtil.trimToNull((String) piece) != null)) { //don't include whitespace before the statement
                        currentString.append(piece);
                    }
                }
                previousDelimiter = false;
            }
            previousPiece = (String) piece;
        }

        String trimmedString = StringUtil.trimToNull(currentString.toString());
        if (trimmedString != null) {
            returnArray.add(trimmedString);
        }

        return returnArray.toArray(new String[returnArray.size()]);
    }
public static String[] processMutliLineSQL(String multiLineSQL, boolean stripComments, boolean splitStatements, String endDelimiter) {

        StringClauses parsed = SqlParser.parse(multiLineSQL, true, !stripComments);

        List<String> returnArray = new ArrayList<>();

        StringBuilder currentString = new StringBuilder();
        String previousPiece = null;
        boolean previousDelimiter = false;
        List<Object> parsedArray = Arrays.asList(parsed.toArray(true));
        for (Object piece : mergeTokens(parsedArray, endDelimiter)) {
            if (splitStatements && (piece instanceof String) && isDelimiter((String) piece, previousPiece, endDelimiter)) {
                String trimmedString = StringUtil.trimToNull(currentString.toString());
                if (trimmedString != null) {
                    returnArray.add(trimmedString);
                }
                currentString = new StringBuilder();
                previousDelimiter = true;
            } else {
                if (!previousDelimiter || (StringUtil.trimToNull((String) piece) != null)) { 
                    if ((currentString.length() > 0) || (StringUtil.trimToNull((String) piece) != null)) { 
                        currentString.append(piece);
                    }
                }
                previousDelimiter = false;
            }
            previousPiece = (String) piece;
        }

        String trimmedString = StringUtil.trimToNull(currentString.toString());
        if (trimmedString != null) {
            returnArray.add(trimmedString);
        }

        return returnArray.toArray(new String[returnArray.size()]);
    }
public static String [ ] processMutliLineSQL ( String multiLineSQL , boolean stripComments , boolean splitStatements , String endDelimiter ) { StringClauses parsed = SqlParser . parse ( multiLineSQL , true , ! stripComments ) ; List < String > returnArray = new ArrayList <> ( ) ; StringBuilder currentString = new StringBuilder ( ) ; String previousPiece = null ; boolean previousDelimiter = false ; List < Object > parsedArray = Arrays . asList ( parsed . toArray ( true ) ) ; for ( Object piece : mergeTokens ( parsedArray , endDelimiter ) ) { if ( splitStatements && ( piece instanceof String ) && isDelimiter ( ( String ) piece , previousPiece , endDelimiter ) ) { String trimmedString = StringUtil . trimToNull ( currentString . toString ( ) ) ; if ( trimmedString != null ) { returnArray . add ( trimmedString ) ; } currentString = new StringBuilder ( ) ; previousDelimiter = true ; } else { if ( ! previousDelimiter || ( StringUtil . trimToNull ( ( String ) piece ) != null ) ) { //don't include whitespace after a delimiter if ( ( currentString . length ( ) > 0 ) || ( StringUtil . trimToNull ( ( String ) piece ) != null ) ) { //don't include whitespace before the statement currentString . append ( piece ) ; } } previousDelimiter = false ; } previousPiece = ( String ) piece ; } String trimmedString = StringUtil . trimToNull ( currentString . toString ( ) ) ; if ( trimmedString != null ) { returnArray . add ( trimmedString ) ; } return returnArray . toArray ( new String [ returnArray . size ( ) ] ) ; }
Removes any comments from multiple line SQL using {@link #stripComments(String)}
and then extracts each individual statement using {@link #splitSQL(String, String)}.

@param multiLineSQL A String containing all the SQL statements
@param stripComments If true then comments will be stripped, if false then they will be left in the code
Removes any comments from multiple line SQL using { @link #stripComments ( String ) } and then extracts each individual statement using { @link #splitSQL ( String String ) } .