Here you can find the source of loadSQLFromFile(String fileName)
Loads teh content of SQL statement from the specified file.
Parameter | Description |
---|---|
fileName | a <code>String</code> providing the path to the target file. |
Parameter | Description |
---|---|
IOException | if an I/O error occurs while reading content of file. |
String
providing the content of the file.
private static String loadSQLFromFile(String fileName) throws IOException
//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(); } }