cdm/src/main/java/ucar/nc2/NCdumpW.java
public static boolean print(String command, Writer out, ucar.nc2.util.CancelTask ct) throws IOException {
    // pull out the filename from the command
    String filename;
    StringTokenizer stoke = new StringTokenizer(command);
    if (stoke.hasMoreTokens())
      filename = stoke.nextToken();
    else {
      out.write(usage);
      return false;
    }

    try (NetcdfFile nc = NetcdfDataset.openFile(filename, ct)) {
      // the rest of the command
      int pos = command.indexOf(filename);
      command = command.substring(pos + filename.length());
      return print(nc, command, out, ct);

    } catch (java.io.FileNotFoundException e) {
      out.write("file not found= ");
      out.write(filename);
      return false;

    } finally {
      out.close();
    }
  }
public static boolean print(String command, Writer out, ucar.nc2.util.CancelTask ct) throws IOException {
    // pull out the filename from the command
    String filename;
    StringTokenizer stoke = new StringTokenizer(command);
    if (stoke.hasMoreTokens())
      filename = stoke.nextToken();
    else {
      out.write(usage);
      return false;
    }

    try (NetcdfFile nc = NetcdfDataset.openFile(filename, ct)) {
      // the rest of the command
      int pos = command.indexOf(filename);
      command = command.substring(pos + filename.length());
      return print(nc, command, out, ct);

    } catch (java.io.FileNotFoundException e) {
      out.write("file not found= ");
      out.write(filename);
      return false;

    } finally {
      out.close();
    }
  }
public static boolean print ( String command , Writer out , ucar . nc2 . util . CancelTask ct ) throws IOException { // pull out the filename from the command String filename ; StringTokenizer stoke = new StringTokenizer ( command ) ; if ( stoke . hasMoreTokens ( ) ) filename = stoke . nextToken ( ) ; else { out . write ( usage ) ; return false ; } try ( NetcdfFile nc = NetcdfDataset . openFile ( filename , ct ) ) { // the rest of the command int pos = command . indexOf ( filename ) ; command = command . substring ( pos + filename . length ( ) ) ; return print ( nc , command , out , ct ) ; } catch ( java . io . FileNotFoundException e ) { out . write ( "file not found= " ) ; out . write ( filename ) ; return false ; } finally { out . close ( ) ; } }
ncdump that parses a command string.

@param command command string
@param out     send output here
@param ct      allow task to be cancelled; may be null.
@return true if successful
@throws IOException on write error
ncdump that parses a command string .