Java URL Load readSqlStatements(URL url)

Here you can find the source of readSqlStatements(URL url)

Description

Reads SQL statements from file.

License

Open Source License

Parameter

Parameter Description
url url of the file

Return

array of command strings

Declaration

private static String[] readSqlStatements(URL url) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class Main {
    /**/*  www  .j a v a 2 s .co  m*/
     * Reads SQL statements from file. SQL commands in file must be separated by
     * a semicolon.
     *
     * @param url url of the file
     * @return array of command strings
     */
    private static String[] readSqlStatements(URL url) {
        try {
            char buffer[] = new char[256];
            StringBuilder result = new StringBuilder();
            InputStreamReader reader = new InputStreamReader(url.openStream(), "UTF-8");
            while (true) {
                int count = reader.read(buffer);
                if (count < 0) {
                    break;
                }
                result.append(buffer, 0, count);
            }
            return result.toString().split(";");
        } catch (IOException ex) {
            throw new RuntimeException("Cannot read " + url, ex);
        }
    }
}

Related

  1. readProperties(URL resource)
  2. readPropertyFile(URL url)
  3. readResource(final URL filename)
  4. readResource(URL resource)
  5. readServicesFromUrl(Collection list, URL url)
  6. readStopwordsURL(URL url, boolean lowercase)
  7. readStringFromUrl(URL url)
  8. readStringFromURL(URL url)
  9. readText(final URL url)