How to open a file from res folder with Program.launch()?

I have a pdf file stored in res folder of my project. I want to give the file to the system for be openned with installed software on the system, using Program.launch().

The problem is that it doesn't works. Program.launch() needs the path to the file stored in res folder, so I tryed to get the path using a function and I passed it to Program.launch()

this is the code:

Program.launch(Util.getPathToFileInResFolder("help.pdf"));

public static String getPathToFileInResFolder(String fileName) {

String path = null;

try {

URL url = ClassLoader.getSystemClassLoader().getResource(fileName);

path = url.toURI().getPath();

} catch (URISyntaxException e) {

e.printStackTrace();

}

return path;

}

It doesn't works...

Read More »

By: StackOverFlow - 7 days ago

Related Posts