Package ucar.nc2

Class FileWriter2


  • @Deprecated
    public class FileWriter2
    extends Object
    Deprecated.
    use NetcdfCopier (library) or Nccopy (command line)
    Utility class for copying a NetcdfFile object, or parts of one, to a netcdf-3 or netcdf-4 disk file. Uses NetcdfFileWriter. This handles the entire CDM model (groups, etc) if you are writing to netcdf-4.

    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 NetcdfFileWriter object for a lower level API.

    • Constructor Detail

      • FileWriter2

        public FileWriter2​(NetcdfFile fileIn,
                           String fileOutName,
                           NetcdfFileWriter.Version version,
                           Nc4Chunking chunker)
                    throws IOException
        Deprecated.
        Use this constructor to copy entire file. Use this.write() to do actual copy.
        Parameters:
        fileIn - copy this file
        fileOutName - to this output file
        version - output file version
        chunker - chunking strategy (netcdf4 only)
        Throws:
        IOException - on read/write error
      • FileWriter2

        public FileWriter2​(NetcdfFileWriter fileWriter)
        Deprecated.
        Use this constructor to copy specific variables to new file. Only supports classic mode

        Use addVariable() to load in variables, then this.write().

        Parameters:
        fileWriter - this encapsolates new file.
    • Method Detail

      • setDebugFlags

        public static void setDebugFlags​(DebugFlags debugFlags)
        Deprecated.
        Set debugging flags
        Parameters:
        debugFlags - debug flags
      • getNetcdfFileWriter

        public NetcdfFileWriter getNetcdfFileWriter()
        Deprecated.
      • addVariable

        public Variable addVariable​(Variable oldVar)
        Deprecated.
        Specify which variable will get written
        Parameters:
        oldVar - add this variable, and all parent groups
        Returns:
        new Variable.
      • write

        public NetcdfFile write​(CancelTask cancel)
                         throws IOException
        Deprecated.
        Write the input file to the output file.
        Parameters:
        cancel - allow user to cancel; may be null.
        Returns:
        the open output file.
        Throws:
        IOException
      • copyVarData

        public double copyVarData​(List<Variable> oldVars,
                                  Structure recordVar,
                                  CancelTask cancel)
                           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:
        oldVars - list of variables from the original file, with data in them
        recordVar - the record variable from the original file, or null means dont use record variables
        cancel - allow user to cancel, may be null.
        Returns:
        total number of bytes written
        Throws:
        IOException - if I/O error
      • main

        @Deprecated
        public static void main​(String[] arg)
                         throws IOException
        Deprecated.
        use ucar.nc2.write.Nccopy
        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
        Parameters:
        arg - -in fileIn -out fileOut [-netcdf4]
        Throws:
        IOException - on read or write error