public class FileHandle extends BaseHandle<File,File> implements ContentHandle<File>, BinaryReadHandle, BinaryWriteHandle, GenericReadHandle, GenericWriteHandle, JSONReadHandle, JSONWriteHandle, TextReadHandle, TextWriteHandle, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, QuadsWriteHandle, TriplesReadHandle, TriplesWriteHandle
A File Handle represents document content as a file for reading or writing.
When you read a database document into a file handle, the API creates a temporary file. You can then open the file or move it with the File.renameTo() method.
When writing JSON, text, or XML content, you should use a File only if the file is encoded in UTF-8. If the characters have a different encoding, use a ReaderHandle and specify the correct character encoding for the file when creating the Reader.
UNKNOWN_LENGTH| Constructor and Description |
|---|
FileHandle()
Zero-argument constructor.
|
FileHandle(File content)
Initializes the handle with a file containing the content.
|
| Modifier and Type | Method and Description |
|---|---|
File |
get()
Returns the file for the handle content.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a FileHandle for a file.
|
void |
set(File content)
Assigns a file as the content.
|
FileHandle |
with(File content)
Assigns a file as the content and returns the handle as a fluent convenience.
|
FileHandle |
withFormat(Format format)
Specifies the format of the content and returns the handle as a fluent convenience.
|
FileHandle |
withMimetype(String mimetype)
Specifies the mime type of the content and returns the handle as a fluent convenience.
|
getByteLength, getFormat, getMimetype, getServerTimestamp, setByteLength, setFormat, setMimetype, setServerTimestamppublic FileHandle()
Zero-argument constructor.
public FileHandle(File content)
Initializes the handle with a file containing the content.
content - the filepublic static ContentHandleFactory newFactory()
Creates a factory to create a FileHandle for a file.
public File get()
Returns the file for the handle content.
get in interface ContentHandle<File>public void set(File content)
Assigns a file as the content.
set in interface ContentHandle<File>content - the filepublic FileHandle with(File content)
Assigns a file as the content and returns the handle as a fluent convenience.
content - the filepublic FileHandle withFormat(Format format)
Specifies the format of the content and returns the handle as a fluent convenience.
format - the format of the contentpublic FileHandle withMimetype(String mimetype)
Specifies the mime type of the content and returns the handle as a fluent convenience.
mimetype - the mime type of the contentCopyright © 2013-2017 MarkLogic Corporation.