## ucar.netcdf
Class NetcdfFile

    java.lang.Object
      ucar.netcdf.AbstractNetcdf
          ucar.netcdf.NetcdfFile

All Implemented Interfaces:
  Netcdf

public class NetcdfFile
extends AbstractNetcdf

A concrete implementation of the Netcdf interface, this class provides connection to NetCDF version 1 files.

Constructors for creating new files and opening existing ones.

See Also:
  `Netcdf`

Nested Class Summary
`(package private) class` `NetcdfFile.V1Io`

Field Summary
`(package private) static String` `_FillValue`
`(package private) static int` `NC_ATTRIBUTE`
`(package private) static int` `NC_BYTE`
`(package private) static int` `NC_CHAR`
`(package private) static int` `NC_DIMENSION`
`(package private) static int` `NC_DOUBLE`
`(package private) static byte` `NC_FILL_BYTE`
`(package private) static byte` `NC_FILL_CHAR`
`(package private) static double` `NC_FILL_DOUBLE`
`(package private) static float` `NC_FILL_FLOAT`
`(package private) static int` `NC_FILL_INT`
`(package private) static short` `NC_FILL_SHORT`
`(package private) static int` `NC_FLOAT`
`(package private) static int` `NC_INT`
`(package private) static int` `NC_SHORT`
`(package private) static int` `NC_VARIABLE`
`(package private) static int` `v1magic`
`(package private) static int` `X_ALIGN`
`(package private) static int` `X_SIZEOF_BYTE`
`(package private) static int` `X_SIZEOF_CHAR`
`(package private) static int` `X_SIZEOF_DOUBLE`
`(package private) static int` `X_SIZEOF_FLOAT`
`(package private) static int` `X_SIZEOF_INT`
`(package private) static int` `X_SIZEOF_SHORT`

Constructor Summary
`NetcdfFile(File file, boolean readonly)` Open existing netcdf version 1 file.
`NetcdfFile(File file, boolean clobber, boolean fill, Schema template)` Create a new netcdf version 1 file from a Schema template.
`NetcdfFile(String path, boolean ro)` Open existing netcdf version 1 file.
`NetcdfFile(String path, boolean clobber, boolean fill, Schema template)` Create a new netcdf version 1 file from a Schema template.
`NetcdfFile(URL url)` Open existing, read-only netcdf file through a URL.

Method Summary
`void` `close()` Close this netcdf file.
`(package private) void` `fillRec(int recno)`
`protected void` `finalize()` Ensures that the close method of this file is called when there are no more references to it.
`void` `flush()` Flush anything written to disk.
`File` `getFile()` Useful for identifying this instance among others.
`boolean` `getFill()` Get the current "fill mode".
`String` `getName()` Useful for identifying this instance among others.
`protected Accessor` `ioFactory(ProtoVariable proto)` Used when creating variables to populate this.
`void` `setFill(boolean pleaseFill)` Sets the "fill mode" to the argument.
`void` `toCdl(StringBuffer buf)` Format as CDL.
`UnlimitedDimension` `unlimitedDimension()` Deprecated.

Methods inherited from class ucar.netcdf.AbstractNetcdf
`add, contains, contains, get, getAttribute, getAttributes, getDimensions, getSchema, indexOf, initHashtable, iterator, putAttribute, putDimension, size, toString, varCtorParameterTypes`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### v1magic

    static final int v1magic

See Also:
  Constant Field Values

### NC_BYTE

    static final int NC_BYTE

See Also:
  Constant Field Values

### NC_CHAR

    static final int NC_CHAR

See Also:
  Constant Field Values

### NC_SHORT

    static final int NC_SHORT

See Also:
  Constant Field Values

### NC_INT

    static final int NC_INT

See Also:
  Constant Field Values

### NC_FLOAT

    static final int NC_FLOAT

See Also:
  Constant Field Values

### NC_DOUBLE

    static final int NC_DOUBLE

See Also:
  Constant Field Values

### NC_DIMENSION

    static final int NC_DIMENSION

See Also:
  Constant Field Values

### NC_VARIABLE

    static final int NC_VARIABLE

See Also:
  Constant Field Values

### NC_ATTRIBUTE

    static final int NC_ATTRIBUTE

See Also:
  Constant Field Values

### X_ALIGN

    static final int X_ALIGN

See Also:
  Constant Field Values

### X_SIZEOF_CHAR

    static final int X_SIZEOF_CHAR

See Also:
  Constant Field Values

### X_SIZEOF_BYTE

    static final int X_SIZEOF_BYTE

See Also:
  Constant Field Values

### X_SIZEOF_SHORT

    static final int X_SIZEOF_SHORT

See Also:
  Constant Field Values

### X_SIZEOF_INT

    static final int X_SIZEOF_INT

See Also:
  Constant Field Values

### X_SIZEOF_FLOAT

    static final int X_SIZEOF_FLOAT

See Also:
  Constant Field Values

### X_SIZEOF_DOUBLE

    static final int X_SIZEOF_DOUBLE

See Also:
  Constant Field Values

### _FillValue

    static final String _FillValue

See Also:
  Constant Field Values

### NC_FILL_BYTE

    static final byte NC_FILL_BYTE

See Also:
  Constant Field Values

### NC_FILL_CHAR

    static final byte NC_FILL_CHAR

See Also:
  Constant Field Values

### NC_FILL_SHORT

    static final short NC_FILL_SHORT

See Also:
  Constant Field Values

### NC_FILL_INT

    static final int NC_FILL_INT

See Also:
  Constant Field Values

### NC_FILL_FLOAT

    static final float NC_FILL_FLOAT

See Also:
  Constant Field Values

### NC_FILL_DOUBLE

    static final double NC_FILL_DOUBLE

See Also:
  Constant Field Values

Constructor Detail

### NetcdfFile

    public NetcdfFile(File file,
                      boolean clobber,
                      boolean fill,
                      Schema template)
               throws IOException

  Create a new netcdf version 1 file from a Schema template.

Parameters:
  `file` - the file name as File object
  `clobber` - if `true`, overwrite existing
  `fill` - if `false`, suppress variable pre fill
  `template` - the Schema used as construction template. May be empty, shouldn't be null.
See Also:
  `setFill(boolean)`, `Netcdf`

### NetcdfFile

    public NetcdfFile(String path,
                      boolean clobber,
                      boolean fill,
                      Schema template)
               throws IOException

  Create a new netcdf version 1 file from a Schema template.

Parameters:
  `path` - the file name as a String
  `clobber` - if `true`, overwrite existing
  `fill` - if `false`, suppress variable pre fill
  `template` - the Schema used as construction template. May be empty, shouldn't be null.
See Also:
  `setFill(boolean)`, `Netcdf`

### NetcdfFile

    public NetcdfFile(File file,
                      boolean readonly)
               throws IOException

  Open existing netcdf version 1 file.

Parameters:
  `file` - the file name as File object
  `readonly` - if `true`, open read only, else open for read and write.

### NetcdfFile

    public NetcdfFile(String path,
                      boolean ro)
               throws IOException

  Open existing netcdf version 1 file.

Parameters:
  `path` - the file name as a String

### NetcdfFile

    public NetcdfFile(URL url)
               throws FileNotFoundException,
                      IOException

  Open existing, read-only netcdf file through a URL. This may use either the file: or http: protocol. If it uses the file protocol, it will be opened as a read-only file using url.getFile(). If it uses the http protocol, it will be read over http using HTTPRandomAccessFile. The query component of the URL is ignored

  Modified from ncBrowse (Donald Denbo).

Parameters:
  `url` - the URL of the netCDF dataset.
Throws:
  `FileNotFoundException` - if the URL specifies a file that doesn't exist.
  `IOException` - if an I/O failure occurs.

Method Detail

### close

    public void close()
               throws IOException

  Close this netcdf file. The inquiry interface calls will continue to be available, but I/O accesses will fail after this call.

  Throws:
    `IOException`
  See Also:
    `RandomAccessFile.close()`

### flush

    public void flush()
               throws IOException

  Flush anything written to disk.

  Throws:
    `IOException`
  See Also:
    `RandomAccessFile.flush()`

### getFile

    public final File getFile()

  Useful for identifying this instance among others.

  Returns:
    File object this was opened or created as.

### getName

    public final String getName()

  Useful for identifying this instance among others.

  Returns:
    File object this was opened or created as.

### setFill

    public void setFill(boolean pleaseFill)

  Sets the "fill mode" to the argument. If true (the default), new storage is prefilled with the appropriate fill value. Otherwise, this activity is suppressed and the programmer should initialize all values.

  Parameters:
    `pleaseFill` - true to fill.
  See Also:
    `getFill()`

### getFill

    public final boolean getFill()

  Get the current "fill mode".

  Returns:
    true iff we are prefilling new storage with the appropriate fill value.
  See Also:
    `setFill(boolean)`

### unlimitedDimension

    public final UnlimitedDimension unlimitedDimension()

  Deprecated.

  If this has an unlimited Dimension, return it, otherwise null. Note that this specific to NetcdfFile, not part of the Netcdf interface. Other implementations may support multiple unlimited dimensions.

  Returns:
    UnlimitedDimension the unlimited dimension

### toCdl

    public void toCdl(StringBuffer buf)

  Format as CDL.

  Overrides:
    `toCdl` in class `AbstractNetcdf`
  Parameters:
    `buf` - StringBuffer into which to write

### ioFactory

    protected Accessor ioFactory(ProtoVariable proto)

  Description copied from class: `AbstractNetcdf`
  Used when creating variables to populate this. Override in your implementation to provide the correct i/o functionality.

  Specified by:
    `ioFactory` in class `AbstractNetcdf`

### fillRec

    void fillRec(int recno)
           throws IOException

  Throws:
    `IOException`

### finalize

    protected void finalize()
                     throws Throwable

  Ensures that the close method of this file is called when there are no more references to it.

  Throws:
    `Throwable` - The lack of covariance for exception specifications dictates the specificed type; it can actually only be `IOException` thrown by `RandomAccessFile.close`.
  See Also:
    `close()`