cdm/src/main/java/ucar/nc2/iosp/netcdf3/N3channelWriter.java
public static void writeFromFile(NetcdfFile fileIn, String fileOutName) throws IOException, InvalidRangeException {

    try (FileOutputStream stream = new FileOutputStream(fileOutName)) {
      WritableByteChannel channel = stream.getChannel();
      DataOutputStream dout = new DataOutputStream(Channels.newOutputStream(channel));

      N3channelWriter writer = new N3channelWriter(fileIn);
      int numrec = fileIn.getUnlimitedDimension() == null ? 0 : fileIn.getUnlimitedDimension().getLength();

      writer.writeHeader(dout, numrec);
      dout.flush();

      writer.writeDataAll(channel);
    }
  }
public static void writeFromFile(NetcdfFile fileIn, String fileOutName) throws IOException, InvalidRangeException {

    try (FileOutputStream stream = new FileOutputStream(fileOutName)) {
      WritableByteChannel channel = stream.getChannel();
      DataOutputStream dout = new DataOutputStream(Channels.newOutputStream(channel));

      N3channelWriter writer = new N3channelWriter(fileIn);
      int numrec = fileIn.getUnlimitedDimension() == null ? 0 : fileIn.getUnlimitedDimension().getLength();

      writer.writeHeader(dout, numrec);
      dout.flush();

      writer.writeDataAll(channel);
    }
  }
//////////////////////////////////////