boolean writeNcml ( String location ) { boolean err = false ; closeOpenFiles ( ) ; try { final String result ; ds = openDataset ( location , addCoords , null ) ; if ( ds == null ) { editor . setText ( "Failed to open <" + location + ">" ) ; } else { final NcMLWriter ncmlWriter = new NcMLWriter ( ) ; final Element netcdfElem = ncmlWriter . makeNetcdfElement ( ds , null ) ; result = ncmlWriter . writeToString ( netcdfElem ) ; editor . setText ( result ) ; editor . setCaretPosition ( 0 ) ; } } catch ( Exception e ) { final StringWriter sw = new StringWriter ( 10000 ) ; e . printStackTrace ( ) ; e . printStackTrace ( new PrintWriter ( sw ) ) ; editor . setText ( sw . toString ( ) ) ; err = true ; } return ! err ; }
write ncml from given dataset