code: public static List<String> parseSQLStatements(final InputStream stream) {
  
  		List<String> statements = new ArrayList<>();
  
  		// Use multiple newlines as the delimiter
  		Scanner s = new Scanner(stream);
  		try {
  			s.useDelimiter(Pattern.compile("\\n\\s*\\n"));
  			// Parse and add each statement
  			while (s.hasNext()) {
  				String statement = s.next().trim();
  				statements.add(statement);
  			}
  		} finally {
  			s.close();
  		}
  
  		return statements;
  	}
docs: Parse the SQL statements for the input stream
  
  @param stream
  input stream
  @return list of sql statements