Package ucar.nc2
Class FileWriter
- java.lang.Object
-
- ucar.nc2.FileWriter
-
public class FileWriter extends Object
Deprecated.use FileWriter2Copy a NetcdfFile to a Netcdf-3 local file. This allows you, for example, to create a "view" of another NetcdfFile using NcML, and/or to write a remote or OpenDAP file into a local netcdf file. All metadata and data is copied out of the NetcdfFile and into the NetcdfFileWritable. The fileIn may be an NcML file which has a referenced dataset in the location URL, the underlying data (modified by the NcML) is written to the new file. If the NcML does not have a referenced dataset, then the new file is filled with fill values, like ncgen.Use the static methods writeToFile() to copy an entire file. Create a FileWriter object to control exactly what gets written to the file.
- See Also:
NetcdfFile
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileWriter.ChunkingIndex
Deprecated.use FileWriter2.ChunkingIndexstatic class
FileWriter.FileWriterProgressEvent
Deprecated.use FileWriter2.FileWriterProgressEventstatic interface
FileWriter.FileWriterProgressListener
Deprecated.
-
Constructor Summary
Constructors Constructor Description FileWriter(String fileOutName, boolean fill)
Deprecated.For writing parts of a NetcdfFile to a new Netcdf-3 local file.FileWriter(String fileOutName, boolean fill, boolean isLargeFile, int extraHeaderBytes)
Deprecated.For writing parts of a NetcdfFile to a new Netcdf-3 local file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static double
copyVarData(NetcdfFileWriteable ncfile, List<Variable> varlist, Structure recordVar, long delay)
Deprecated.static double
copyVarData(NetcdfFileWriteable ncfile, List<Variable> varlist, Structure recordVar, List<FileWriter.FileWriterProgressListener> progressListeners)
Deprecated.Write data from varList into new file.void
finish()
Deprecated.Call this when all attributes, dimensions, and variables have been added.NetcdfFileWriteable
getNetcdf()
Deprecated.Get underlying NetcdfFileWriteablestatic void
main(String[] arg)
Deprecated.Main program.static void
setDebugFlags(DebugFlags debugFlags)
Deprecated.Set debugging flagsvoid
writeAttribute(String varName, Attribute att)
Deprecated.Write a Variable attribute to the file.Dimension
writeDimension(Dimension dim)
Deprecated.Add a Dimension to the filevoid
writeGlobalAttribute(Attribute att)
Deprecated.Write a global attribute to the file.static NetcdfFile
writeToFile(NetcdfFile fileIn, String fileOutName)
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format.static NetcdfFile
writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill)
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format.static NetcdfFile
writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, boolean isLargeFile)
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format.static NetcdfFile
writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, boolean isLargeFile, List<FileWriter.FileWriterProgressListener> progressListeners)
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format.static NetcdfFile
writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, int delay)
Deprecated.static NetcdfFile
writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, int delay, boolean isLargeFile)
Deprecated.void
writeVariable(Variable oldVar)
Deprecated.Add a Variable to the file.void
writeVariables(List<Variable> varList)
Deprecated.Add a list of Variables to the file.
-
-
-
Constructor Detail
-
FileWriter
public FileWriter(String fileOutName, boolean fill) throws IOException
Deprecated.For writing parts of a NetcdfFile to a new Netcdf-3 local file. To copy all the contents, the static method FileWriter.writeToFile() is preferred. These are mostly convenience methods on top of NetcdfFileWriteable.- Parameters:
fileOutName
- file name to write to.fill
- use fill mode or not- Throws:
IOException
- on bad
-
FileWriter
public FileWriter(String fileOutName, boolean fill, boolean isLargeFile, int extraHeaderBytes) throws IOException
Deprecated.For writing parts of a NetcdfFile to a new Netcdf-3 local file. To copy all the contents, the static method FileWriter.writeToFile() is preferred. These are mostly convenience methods on top of NetcdfFileWriteable.- Parameters:
fileOutName
- file name to write to.fill
- use fill mode or notisLargeFile
- true if large file formatextraHeaderBytes
- add extra bytes in the header, or -1- Throws:
IOException
- on bad
-
-
Method Detail
-
setDebugFlags
public static void setDebugFlags(DebugFlags debugFlags)
Deprecated.Set debugging flags- Parameters:
debugFlags
- debug flags
-
writeToFile
public static NetcdfFile writeToFile(NetcdfFile fileIn, String fileOutName) throws IOException
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format. Cannot do groups, etc, until we get a Netcdf-4 file format.- Parameters:
fileIn
- write from this NetcdfFilefileOutName
- write to this local file- Returns:
- NetcdfFile that was written to. It remains open for reading or writing.
- Throws:
IOException
- on read or write error
-
writeToFile
public static NetcdfFile writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill) throws IOException
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format. Cannot do groups, etc, until we get a Netcdf-4 file format.- Parameters:
fileIn
- write from this NetcdfFilefileOutName
- write to this local filefill
- use fill mode- Returns:
- NetcdfFile that was written to. It remains open for reading or writing.
- Throws:
IOException
- on read or write error
-
writeToFile
public static NetcdfFile writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, boolean isLargeFile) throws IOException
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format. Cannot do groups, etc, until we get a Netcdf-4 file format.- Parameters:
fileIn
- write from this NetcdfFilefileOutName
- write to this local filefill
- use fill modeisLargeFile
- if true, make large file format (> 2Gb offsets)- Returns:
- NetcdfFile that was written to. It remains open for reading or writing.
- Throws:
IOException
- on read or write error
-
writeToFile
public static NetcdfFile writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, boolean isLargeFile, List<FileWriter.FileWriterProgressListener> progressListeners) throws IOException
Deprecated.Copy a NetcdfFile to a physical file, using Netcdf-3 file format.- Parameters:
fileIn
- write from this NetcdfFilefileOutName
- write to this local filefill
- use fill modeisLargeFile
- if true, make large file format (> 2Gb offsets)progressListeners
- List of progress listeners, use null or empty list if there are none.- Returns:
- NetcdfFile that was written. It remains open for reading or writing.
- Throws:
IOException
- on read or write error
-
copyVarData
public static double copyVarData(NetcdfFileWriteable ncfile, List<Variable> varlist, Structure recordVar, List<FileWriter.FileWriterProgressListener> progressListeners) throws IOException
Deprecated.Write data from varList into new file. Read/Write a maximum of maxSize bytes at a time. When theres a record variable, its much more efficient to use it.- Parameters:
ncfile
- write tot this filevarlist
- list of varibles from the original file, with data in themrecordVar
- the record variable from the original file, or null means dont use record variablesprogressListeners
- List of progress event listeners, may be null- Returns:
- total number of bytes written
- Throws:
IOException
- if I/O error
-
getNetcdf
public NetcdfFileWriteable getNetcdf()
Deprecated.Get underlying NetcdfFileWriteable- Returns:
- underlying NetcdfFileWriteable
-
writeGlobalAttribute
public void writeGlobalAttribute(Attribute att)
Deprecated.Write a global attribute to the file.- Parameters:
att
- take attribute name, value, from here
-
writeAttribute
public void writeAttribute(String varName, Attribute att)
Deprecated.Write a Variable attribute to the file.- Parameters:
varName
- name of variable to attach attribute toatt
- take attribute name, value, from here
-
writeDimension
public Dimension writeDimension(Dimension dim)
Deprecated.Add a Dimension to the file- Parameters:
dim
- copy this dimension- Returns:
- the new Dimension
-
writeVariable
public void writeVariable(Variable oldVar)
Deprecated.Add a Variable to the file. The data is copied when finish() is called. The variable's Dimensions are added for you, if not already been added.- Parameters:
oldVar
- copy this Variable to new file.
-
writeVariables
public void writeVariables(List<Variable> varList)
Deprecated.Add a list of Variables to the file. The data is copied when finish() is called. The Variables' Dimensions are added for you, if not already been added.- Parameters:
varList
- list of Variable
-
finish
public void finish() throws IOException
Deprecated.Call this when all attributes, dimensions, and variables have been added. The data from all Variables will be written to the file. You cannot add any other attributes, dimensions, or variables after this call.- Throws:
IOException
- on read or write error
-
copyVarData
public static double copyVarData(NetcdfFileWriteable ncfile, List<Variable> varlist, Structure recordVar, long delay) throws IOException
Deprecated.- Throws:
IOException
-
writeToFile
public static NetcdfFile writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, int delay) throws IOException
Deprecated.- Throws:
IOException
-
writeToFile
public static NetcdfFile writeToFile(NetcdfFile fileIn, String fileOutName, boolean fill, int delay, boolean isLargeFile) throws IOException
Deprecated.- Throws:
IOException
-
main
public static void main(String[] arg) throws IOException
Deprecated.Main program.ucar.nc2.FileWriter -in fileIn -out fileOut.
where:
- fileIn : path of any CDM readable file
- fileOut: local pathname where netdf-3 file will be written
- delay: if set and file has record dimension, delay between writing each record, for testing files that are growing
- Parameters:
arg
- -in fileIn -out fileOut- Throws:
IOException
- on read or write error
-
-