I have a java applet that contains resources directory (Directory name is: Resources) this directory contains some dll files. (This directory/folder is packaged in the jar file for the applet).
I am trying to extract the contents of this directory to the local hard disk. I am using
getClass().getClassLoader().getResourceAsStream("Resources/" + fileName);
to get the file and save it to another path so i can access it. This method is working before deploying/embedding my applet to a HTML page.
I Have two problems:
1- After deploying on a web server, this method returns null.
2- How to enumerate all files in the resources folder after deploying my applet, so that i can save these files to another path.
Sorry if my question is stupid, simple or unclear because this is the first Java applet for me.
I am suggesting an alternative for your second question. You could run OS commands in your java code to do these operations. If you are on a linux environment to extract the whole folder and copy somewhere else you can run
jar xf yourjarfile.jar Resources
cp -rf Resources toSomewhereElse/
in your java code. You can find examples here to see how to run OS commands in your Java code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.