Java BufferedReader Read loadSQLFromFile(String fileName)

Here you can find the source of loadSQLFromFile(String fileName)

Description

Loads teh content of SQL statement from the specified file.

License

Open Source License

Parameter

Parameter Description
fileName a <code>String</code> providing the path to the target file.

Exception

Parameter Description
IOException if an I/O error occurs while reading content of file.

Return

a String providing the content of the file.

Declaration

private static String loadSQLFromFile(String fileName) throws IOException 

Method Source Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Main {
    /**/* w w  w  .  ja v a2 s.  c om*/
     * <p>Loads teh content of SQL statement from the specified file.</p>
     * 
     * @param fileName a <code>String</code> providing the path to the target file.
     * @return a <code>String</code> providing the content of the file.
     * @throws IOException if an I/O error occurs while reading content of file.
     */
    private static String loadSQLFromFile(String fileName) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(fileName));
        String line;
        StringBuilder sql = new StringBuilder();
        try {
            while ((line = reader.readLine()) != null) {
                sql.append(line).append(" ");
            }
        } finally {
            reader.close();
        }

        return sql.toString();
    }
}

Related

  1. loadReaderToList(Reader reader)
  2. loadRealDataGraphFromEmbers(String fileName, String splitter)
  3. loadSentences(InputStream stream, List jsonSentences)
  4. loadSimpleTextFile(File file, int bufferSize)
  5. loadSqlFile(String path)
  6. loadStream(InputStream is)
  7. loadStreamContent(InputStream stream)
  8. loadSystemClassPath()
  9. loadTableList(List list, String fileName)