public class TextWriter extends EarthDataWriter
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CHUNK_SIZE
Output buffer size in kilobytes.
|
info, isCanceled, variables, writeProgress, writeVariableName, writeVariables
Constructor and Description |
---|
TextWriter(EarthDataInfo info,
java.lang.String file)
Creates a new text file from the specified earth data info
and file name.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the writer and frees any resources.
|
void |
flush()
Flushes all unwritten data to the destination.
|
void |
setCoords(boolean coords)
Sets coordinate printing.
|
void |
setDecimals(int decimals)
Sets the decimal places.
|
void |
setDelimiter(java.lang.String delimiter)
Sets the field delimiter.
|
void |
setHeader(boolean header)
Sets the header flag.
|
void |
setMissing(java.lang.Number missing)
Sets the missing value.
|
void |
setReverse(boolean reverse)
Sets the reverse flag.
|
protected void |
writeHeader(DataVariable var)
Writes a dimension header.
|
protected void |
writeVariable(DataVariable var)
Writes the variable data as a stream of text lines.
|
addVariable, cancel, finalize, getDestination, getProgress, getProgressLength, getProgressVariable
public static final int DEFAULT_CHUNK_SIZE
public TextWriter(EarthDataInfo info, java.lang.String file) throws java.io.IOException
Double.NaN
is used for the missing value.info
- the earth data info object.file
- the new binary file name.java.io.IOException
- if an error occurred opening the file.public void setDecimals(int decimals)
decimals
- the number of decimal places to use in coordinate
value printing.public void setCoords(boolean coords)
coords
- the coordinate flag. If true, the earth location
coordinates are printed along with each data value in the order
latitude, longitude. Otherwise no coordinates are printed.public void setReverse(boolean reverse)
reverse
- the reverse flag.setCoords(boolean)
public void setDelimiter(java.lang.String delimiter)
delimiter
- the field delimiter. The delimiter is used to
separate multiple data fields on one line.public void setHeader(boolean header)
header
- the header flag. If true, a header line is printed
prior to any data values. The header line consists of one
integer specifying the number of dimensions followed by a series
of integers specifying the dimension lengths. If false, no header
line is printed.public void setMissing(java.lang.Number missing)
missing
- the missing value. The missing value is used to
represent missing or out of range data values. The missing value
is printed when such data is encountered in the variable data. If the
missing value is null, the value Double.NaN
is used.protected void writeHeader(DataVariable var) throws java.io.IOException
var
- the data variable to write a header for.java.io.IOException
- if an error occurred writing the header data
to the file.public void flush() throws java.io.IOException
EarthDataWriter
flush
in class EarthDataWriter
java.io.IOException
- if the data destination had I/O errors.protected void writeVariable(DataVariable var) throws java.io.IOException
var
- the data variable to write data for.java.io.IOException
- if an error occurred writing the data
to the file.public void close() throws java.io.IOException
EarthDataWriter
flush
method is called prior to closing.close
in class EarthDataWriter
java.io.IOException
- if the data destination had I/O errors.