Package org.apache.tika.pipes.emitter.fs
Class FileSystemEmitter
- java.lang.Object
-
- org.apache.tika.pipes.emitter.AbstractEmitter
-
- org.apache.tika.pipes.emitter.fs.FileSystemEmitter
-
- All Implemented Interfaces:
org.apache.tika.pipes.emitter.Emitter,org.apache.tika.pipes.emitter.StreamEmitter
public class FileSystemEmitter extends org.apache.tika.pipes.emitter.AbstractEmitter implements org.apache.tika.pipes.emitter.StreamEmitterEmitter to write to a file system.This calculates the path to write to based on the
basePathand the value of theTikaCoreProperties.SOURCE_PATHvalue.<properties> <emitters> <emitter class="org.apache.tika.pipes.emitter.fs.FileSystemEmitter> <params> <!-- required --> <param name="name" type="string">fs</param> <!-- required --> <param name="basePath" type="string">/path/to/output</param> <!-- optional; default is 'json' --> <param name="fileExtension" type="string">json</param> <!-- optional; if the file already exists, options ('skip', 'replace', 'exception') default is 'exception' --> <param name="onExists" type="string">skip</param> <!-- optional; whether or not to pretty print the output default is false --> <param name="prettyPrint" type="boolean">true</param> </params> </emitter> </emitters> </properties>
-
-
Constructor Summary
Constructors Constructor Description FileSystemEmitter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidemit(String path, InputStream inputStream, org.apache.tika.metadata.Metadata userMetadata, org.apache.tika.parser.ParseContext parseContext)voidemit(String emitKey, List<org.apache.tika.metadata.Metadata> metadataList, org.apache.tika.parser.ParseContext parseContext)voidsetBasePath(String basePath)voidsetFileExtension(String fileExtension)If you want to customize the output file's file extension.voidsetOnExists(String onExists)What to do if the target file already exists.voidsetPrettyPrint(boolean prettyPrint)
-
-
-
Method Detail
-
emit
public void emit(String emitKey, List<org.apache.tika.metadata.Metadata> metadataList, org.apache.tika.parser.ParseContext parseContext) throws IOException, org.apache.tika.pipes.emitter.TikaEmitterException
- Specified by:
emitin interfaceorg.apache.tika.pipes.emitter.Emitter- Throws:
IOExceptionorg.apache.tika.pipes.emitter.TikaEmitterException
-
setBasePath
@Field public void setBasePath(String basePath)
-
setFileExtension
@Field public void setFileExtension(String fileExtension)
If you want to customize the output file's file extension. Do not include the "."- Parameters:
fileExtension-
-
setOnExists
@Field public void setOnExists(String onExists)
What to do if the target file already exists. NOTE: if more than one thread is trying write to the same file andFileSystemEmitter.ON_EXISTS.REPLACEis chosen, you still might get aFileAlreadyExistsException.- Parameters:
onExists-
-
setPrettyPrint
@Field public void setPrettyPrint(boolean prettyPrint)
-
emit
public void emit(String path, InputStream inputStream, org.apache.tika.metadata.Metadata userMetadata, org.apache.tika.parser.ParseContext parseContext) throws IOException, org.apache.tika.pipes.emitter.TikaEmitterException
- Specified by:
emitin interfaceorg.apache.tika.pipes.emitter.StreamEmitter- Throws:
IOExceptionorg.apache.tika.pipes.emitter.TikaEmitterException
-
-