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

[414 byte] By [juniorprogrammera] at [2007-11-27 8:36:56]
# 1

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");

}

});

prometheuzza at 2007-7-12 20:34:04 > top of Java-index,Java Essentials,Java Programming...
# 2

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

juniorprogrammera at 2007-7-12 20:34:04 > top of Java-index,Java Essentials,Java Programming...
# 3
> ...> so do i need to add the runtime as above to> run all the ".pps" files?You can answer that question yourself by compiling and executing your code.Do you understand what File[] files = ... does however?
prometheuzza at 2007-7-12 20:34:04 > top of Java-index,Java Essentials,Java Programming...