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