T
- type of elements@PublicEvolving public class TextOutputFormat<T> extends FileOutputFormat<T>
FileOutputFormat
that writes objects to a text file.
Objects are converted to Strings using either Object.toString()
or a TextOutputFormat.TextFormatter
.
Modifier and Type | Class and Description |
---|---|
static interface |
TextOutputFormat.TextFormatter<IN>
Formatter that transforms values into their
String representations. |
FileOutputFormat.OutputDirectoryMode
FILE_PARAMETER_KEY, outputFilePath, stream
Constructor and Description |
---|
TextOutputFormat(Path outputPath) |
TextOutputFormat(Path outputPath,
String charset) |
Modifier and Type | Method and Description |
---|---|
String |
getCharsetName() |
void |
open(int taskNumber,
int numTasks)
Opens a parallel instance of the output format to store the result of its parallel instance.
|
void |
setCharsetName(String charsetName) |
String |
toString() |
void |
writeRecord(T record)
Adds a record to the output.
|
close, configure, getDirectoryFileName, getOutputDirectoryMode, getOutputFilePath, getWriteMode, initDefaultsFromConfiguration, initializeGlobal, setOutputDirectoryMode, setOutputFilePath, setWriteMode, tryCleanupOnError
getRuntimeContext, setRuntimeContext
public TextOutputFormat(Path outputPath)
public String getCharsetName()
public void setCharsetName(String charsetName) throws IllegalCharsetNameException, UnsupportedCharsetException
public void open(int taskNumber, int numTasks) throws IOException
OutputFormat
When this method is called, the output format it guaranteed to be configured.
open
in interface OutputFormat<T>
open
in class FileOutputFormat<T>
taskNumber
- The number of the parallel instance.numTasks
- The number of parallel tasks.IOException
- Thrown, if the output could not be opened due to an I/O problem.public void writeRecord(T record) throws IOException
OutputFormat
When this method is called, the output format it guaranteed to be opened.
record
- The records to add to the output.IOException
- Thrown, if the records could not be added to to an I/O problem.Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.