class NcStreamWriter {

  public long streamAll(OutputStream out) throws IOException, InvalidRangeException {
    long size = writeBytes(out, NcStream.MAGIC_START);
    size += sendHeader(out);

    for (Variable v : ncfile.getVariables()) {
      NcStreamCompression compress;
      String compType = v.findAttributeString(CDM.COMPRESS, null);
      if (compType != null) {
        if (compType.equalsIgnoreCase(CDM.COMPRESS_DEFLATE)) {
          compress = NcStreamCompression.deflate();
        } else {
          compress = NcStreamCompression.none();
        }
      } else {
        compress = NcStreamCompression.none();
      }

      long vsize = v.getSize() * v.getElementSize();
      // if (vsize < sizeToCache) continue; // in the header;
      if (vsize > maxChunk) {
        size += copyChunks(out, v, maxChunk, compress);
      } else {
        size += sendData(v, v.getShapeAsSection(), out, compress);
      }
    }

    size += writeBytes(out, NcStream.MAGIC_END);
    return size;
  }

  public  NcStreamWriter(NetcdfFile ncfile, String location);

}