executing same file extension
hi,
what i did below is only open a specific file.
String fileName ="someFile.pps";
Runtime.getRuntime().exec("cmd /c F:/" + fileName);
how do i want to execute all the files with the same extension".pps" in thef:/ directory and also how do i execute the files when the filename have spaces?
thank you
jp
Try a FileFilter. Here's a little demo:
File root = new File("F:/");
File[] files = root.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile() && file.getName().toLowerCase().endsWith(".pps");
}
});
File h = new File("F://");
if (h.exists()) {
File root = new File("F:/");
File[] files = root.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isFile() && file.getName().toLowerCase().endsWith(".pps");
}
});
try {
Runtime.getRuntime().exec(new String[]{"cmd", "/c", "start"+root});
}
catch (Exception x) {
x.printStackTrace();
}
catch (Error e) {
e.printStackTrace();
}
}
so do i need to add the runtime as above to run all the ".pps" files?
thank you
jp