Package org.h2.store.fs.encrypt
Class FilePathEncrypt
- java.lang.Object
-
- org.h2.store.fs.FilePath
-
- org.h2.store.fs.FilePathWrapper
-
- org.h2.store.fs.encrypt.FilePathEncrypt
-
public class FilePathEncrypt extends FilePathWrapper
An encrypted file.
-
-
Constructor Summary
Constructors Constructor Description FilePathEncrypt()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]getPasswordBytes(char[] passwordChars)Convert a char array to a byte array, in UTF-16 format.protected java.lang.StringgetPrefix()java.lang.StringgetScheme()Get the scheme (prefix) for this file provider.java.io.InputStreamnewInputStream()Create an input stream to read from the file.java.io.OutputStreamnewOutputStream(boolean append)Create an output stream to write into the file.java.nio.channels.FileChannelopen(java.lang.String mode)Open a random access file object.private java.lang.String[]parse(java.lang.String fileName)Split the file name into algorithm, password, and base file name.static voidregister()Register this file system.longsize()Get the size of a file in bytesFilePathunwrap(java.lang.String fileName)Get the base path for the given wrapped path.-
Methods inherited from class org.h2.store.fs.FilePathWrapper
canWrite, createDirectory, createFile, createTempFile, delete, exists, getBase, getParent, getPath, isAbsolute, isDirectory, lastModified, moveTo, newDirectoryStream, setReadOnly, toRealPath, unwrap, wrap
-
Methods inherited from class org.h2.store.fs.FilePath
get, getName, newFileChannelOutputStream, register, toString, unregister
-
-
-
-
Field Detail
-
SCHEME
private static final java.lang.String SCHEME
- See Also:
- Constant Field Values
-
-
Method Detail
-
register
public static void register()
Register this file system.
-
open
public java.nio.channels.FileChannel open(java.lang.String mode) throws java.io.IOExceptionDescription copied from class:FilePathOpen a random access file object.- Overrides:
openin classFilePathWrapper- Parameters:
mode- the access mode. Supported are r, rw, rws, rwd- Returns:
- the file object
- Throws:
java.io.IOException- If an I/O error occurs
-
getScheme
public java.lang.String getScheme()
Description copied from class:FilePathGet the scheme (prefix) for this file provider. This is similar tojava.nio.file.spi.FileSystemProvider.getScheme.
-
getPrefix
protected java.lang.String getPrefix()
- Overrides:
getPrefixin classFilePathWrapper
-
unwrap
public FilePath unwrap(java.lang.String fileName)
Description copied from class:FilePathWrapperGet the base path for the given wrapped path.- Overrides:
unwrapin classFilePathWrapper- Parameters:
fileName- the path including the scheme prefix- Returns:
- the base file path
-
size
public long size()
Description copied from class:FilePathGet the size of a file in bytes- Overrides:
sizein classFilePathWrapper- Returns:
- the size in bytes
-
newOutputStream
public java.io.OutputStream newOutputStream(boolean append) throws java.io.IOExceptionDescription copied from class:FilePathCreate an output stream to write into the file.- Overrides:
newOutputStreamin classFilePathWrapper- Parameters:
append- if true, the file will grow, if false, the file will be truncated first- Returns:
- the output stream
- Throws:
java.io.IOException- If an I/O error occurs
-
newInputStream
public java.io.InputStream newInputStream() throws java.io.IOExceptionDescription copied from class:FilePathCreate an input stream to read from the file.- Overrides:
newInputStreamin classFilePathWrapper- Returns:
- the input stream
- Throws:
java.io.IOException- If an I/O error occurs
-
parse
private java.lang.String[] parse(java.lang.String fileName)
Split the file name into algorithm, password, and base file name.- Parameters:
fileName- the file name- Returns:
- an array with algorithm, password, and base file name
-
getPasswordBytes
public static byte[] getPasswordBytes(char[] passwordChars)
Convert a char array to a byte array, in UTF-16 format. The char array is not cleared after use (this must be done by the caller).- Parameters:
passwordChars- the password characters- Returns:
- the byte array
-
-