I just wantto know how can I know the default program associated with any external program/file. For ex-by default, a java file opens with which program? This I have to know using a Java program itself.
On windows:
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("ftype > %YOUR_DIRECTORY%\\type_program.properties");
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream("%YOUR_DIRECTORY%\\type_program.properties");
prop.load(in);
on Unix\Linux:
you can use file command for specific extension and get the corresponding mapping.
at this point you got all the mappings in your properties object. enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With