Package org.h2.samples

# Class FileFunctions

java.lang.Object
org.h2.samples.FileFunctions

public class FileFunctions extends Object
This 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

Modifier and Type
Method
Description
`static void`
`main(String... args)`
This method is called when executing this sample application from the command line.
`static byte[]`
`readFile(String fileName)`
Read a file into a byte array.
`static String`
`readTextFile(String fileName)`
Read a String from a file.
`static String`
`readTextFileWithEncoding(String fileName, String encoding)`
Read a String from a file using the specified encoding.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FileFunctions

public FileFunctions()

## Method Details

### main

public static void main(String... args) throws Exception
This method is called when executing this sample application from the command line.

Parameters:
  `args` - the command line parameters
Throws:
  `Exception` - on failure

### readTextFile

public static String readTextFile(String fileName) throws IOException
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

public static String readTextFileWithEncoding(String fileName, String encoding) throws IOException
Read a String from a file using the specified encoding.

Parameters:
  `fileName` - the file name
  `encoding` - the encoding
Returns:
  the text
Throws:
  `IOException` - on failure

### readFile

public static byte[] readFile(String fileName) throws IOException
Read a file into a byte array.

Parameters:
  `fileName` - the file name
Returns:
  the byte array
Throws:
  `IOException` - on failure