Package org.h2.samples
Class FileFunctions
- java.lang.Object
-
- org.h2.samples.FileFunctions
-
public class FileFunctions extends java.lang.ObjectThis sample application shows how to create a user defined function to read a file from the file system.
-
-
Constructor Summary
Constructors Constructor Description FileFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidmain(java.lang.String... args)This method is called when executing this sample application from the command line.static byte[]readFile(java.lang.String fileName)Read a file into a byte array.static java.lang.StringreadTextFile(java.lang.String fileName)Read a String from a file.static java.lang.StringreadTextFileWithEncoding(java.lang.String fileName, java.lang.String encoding)Read a String from a file using the specified encoding.
-
-
-
Method Detail
-
main
public static void main(java.lang.String... args) throws java.lang.ExceptionThis method is called when executing this sample application from the command line.- Parameters:
args- the command line parameters- Throws:
java.lang.Exception- on failure
-
readTextFile
public static java.lang.String readTextFile(java.lang.String fileName) throws java.io.IOExceptionRead a String from a file. The default encoding for this platform is used.- Parameters:
fileName- the file name- Returns:
- the text
- Throws:
java.io.IOException- on failure
-
readTextFileWithEncoding
public static java.lang.String readTextFileWithEncoding(java.lang.String fileName, java.lang.String encoding) throws java.io.IOExceptionRead a String from a file using the specified encoding.- Parameters:
fileName- the file nameencoding- the encoding- Returns:
- the text
- Throws:
java.io.IOException- on failure
-
readFile
public static byte[] readFile(java.lang.String fileName) throws java.io.IOExceptionRead a file into a byte array.- Parameters:
fileName- the file name- Returns:
- the byte array
- Throws:
java.io.IOException- on failure
-
-