ucar.nc2
Class FileWriter

java.lang.Object
  extended by ucar.nc2.FileWriter

public class FileWriter
extends java.lang.Object

Copy 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.

Version:
$Revision:51 $ $Date:2006-07-12 17:13:13Z $
Author:
caron
See Also:
NetcdfFile

Constructor Summary
FileWriter(java.lang.String fileOutName, boolean fill)
          For writing parts of a NetcdfFile to a new Netcdf-3 local file.
 
Method Summary
 void finish()
          Call this when all attributes, dimensions, and variables have been added.
static void main(java.lang.String[] arg)
          Main program.
static void setDebugFlags(DebugFlags debugFlags)
           
 void writeAttribute(java.lang.String varName, Attribute att)
          Write a Variable attribute to the file.
 void writeDimension(Dimension dim)
          Add a Dimension to the file
 void writeGlobalAttribute(Attribute att)
          Write a global attribute to the file.
static NetcdfFile writeToFile(NetcdfFile fileIn, java.lang.String fileOutName)
          Copy a NetcdfFile to a physical file, using Netcdf-3 file format.
static NetcdfFile writeToFile(NetcdfFile fileIn, java.lang.String fileOutName, boolean fill)
          Copy a NetcdfFile to a physical file, using Netcdf-3 file format.
static NetcdfFile writeToFile(NetcdfFile fileIn, java.lang.String fileOutName, boolean fill, int delay)
          Copy a NetcdfFile to a physical file, using Netcdf-3 file format.
 void writeVariable(Variable oldVar)
          Add a Variable to the file.
 void writeVariables(java.util.List varList)
          Add a list of Variables to the file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileWriter

public FileWriter(java.lang.String fileOutName,
                  boolean fill)
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
Method Detail

setDebugFlags

public static void setDebugFlags(DebugFlags debugFlags)

writeToFile

public static NetcdfFile writeToFile(NetcdfFile fileIn,
                                     java.lang.String fileOutName)
                              throws java.io.IOException
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 NetcdfFile
fileOutName - write to this local file
Returns:
NetcdfFile that was written to. It remains open for reading or writing.
Throws:
java.io.IOException

writeToFile

public static NetcdfFile writeToFile(NetcdfFile fileIn,
                                     java.lang.String fileOutName,
                                     boolean fill)
                              throws java.io.IOException
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 NetcdfFile
fileOutName - write to this local file
fill - use fill mode
Returns:
NetcdfFile that was written to. It remains open for reading or writing.
Throws:
java.io.IOException

writeToFile

public static NetcdfFile writeToFile(NetcdfFile fileIn,
                                     java.lang.String fileOutName,
                                     boolean fill,
                                     int delay)
                              throws java.io.IOException
Copy a NetcdfFile to a physical file, using Netcdf-3 file format.

Parameters:
fileIn - write from this NetcdfFile
fileOutName - write to this local file
fill - use fill mode
delay - pause this amount (in milliseconds) between writing each record.
Returns:
NetcdfFile that was written. It remains open for reading or writing.
Throws:
java.io.IOException

writeGlobalAttribute

public void writeGlobalAttribute(Attribute att)
Write a global attribute to the file.

Parameters:
att - take attribute name, value, from here

writeAttribute

public void writeAttribute(java.lang.String varName,
                           Attribute att)
Write a Variable attribute to the file.

Parameters:
varName - name of variable to attach attribute to
att - take attribute name, value, from here

writeDimension

public void writeDimension(Dimension dim)
Add a Dimension to the file

Parameters:
dim - copy this dimension

writeVariable

public void writeVariable(Variable oldVar)
Add a Variable to the file. The data is also copied when finish() is called.

Parameters:
oldVar - copy this Variable (not the data)

writeVariables

public void writeVariables(java.util.List varList)
Add a list of Variables to the file. The data is also copied when finish() is called.

Parameters:
varList - list of Variable

finish

public void finish()
            throws java.io.IOException
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:
java.io.IOException

main

public static void main(java.lang.String[] arg)
                 throws java.net.MalformedURLException,
                        java.io.IOException
Main program.

ucar.nc2.FileWriter -in fileIn -out fileOut [-delay millisecs].

where: