NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi, Sorry, I'm a bit late on this, but perhaps some help:
The most likely cause is that you need to "escape" the "\" marks in your path: DisplayCells[0][0].addDataSource("D:\visad\unzipped\visad\ss\small.v5d"); should probably be written as:DisplayCells[0][0].addDataSource("D:\\visad\\unzipped\\visad\\ss\\small.v5d");
or, better still, substitute "/", "\", "\\" or by File.Separator, e.g. DisplayCells[0][0].addDataSource("D:+File.Separator+visad+File.Separator+unzipped... or String s = File.Separator; DisplayCells[0][0].addDataSource("D:"+s+"visad"+s+"unzipped...You can get a list of root drives with File.listRoots(), to get rid of that "d:". But it would be even better to a file chooser dialog, as your app is gui-based. Something like
// not tested! public String chooseFile(String currentDir){ // open dialog JFileChooser fc = new JFileChooser(); // chosse file fc.setCurrentDirectory(new File(currentDir)); int returnVal = fc.showOpenDialog(new JFrame()); if (returnVal == JFileChooser.APPROVE_OPTION) { java.io.File file = fc.getSelectedFile(); System.out.println("Opening: " + file.getAbsolutePath() ); try { String fileName = file.getAbsolutePath(); return filename; }catch (Exception ex) { // something went wrong ex.printStackTrace(); } } else { System.out.println("Open command cancelled by user."); } return null; } and then, in your app: String file = chooseFile("d:\\visad\\..."); (I think chooseFile(".") might work) if( file != null) DisplayCells[0][0].addDataSource(file); Hope this helps a little. Cheers, Ugo
visad
archives: