Hello,
For some reason when uploadDir is set to commented value I am only able to open files where the names
do not contain spaces. For example a
doc named "Test Me.doc" will not be found to load but if the file is named "TestMe.doc"
there will be no issues. Please note that this
applet is not being run from a webserver; it is being executed from a shared drive on
a windows server.
Code That works......
String launchLocation = this.getCodeBase().getFile();
char drive = launchLocation.charAt(1);
String driveLetter = String.valueOf(drive);
uploadDir = driveLetter + ":/NY_GEIT_ETMS/GPS_KNOWLEDGE/upload/";
Code That will not allow spaces in file names.
//uploadDir = File.separator + File.separator + "acntnyc032" + File.separator + "dept" + File.separator + "NY_GEIT_ETMS" + File.separator + "GPS_KNOWLEDGE" + File.separator + "upload" + File.separator;
Code which launches doc
private void DocumentButtonMousePressed(java.awt.event.MouseEvent evt) {
// Open Document Code Here
String PATH = uploadDir;
String completePath = PATH + currentDocument;
File docToOpen = new File(completePath);
Desktop desktop;
if (Desktop.isDesktopSupported()) {
try {
desktop = Desktop.getDesktop();
desktop.open(docToOpen);
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
I have played around with the below code but it also gives me an issue loading files with spaces in the name.
//File x = new File(this.getCodeBase().getPath());
//String xx = x.getPath() + File.separator + "upload" + File.separator;
//uploadDir = xx;
//System.out.print(xx);
Any help would be great. I am trying to avoid using drive names in the code at all cost.
Thanks