I try to load the File from RAR . I am using the
sFileName=Thread.currentThread().getContextClassLoader().getResource("common.xml").getFile();
Immediately, my requirement is load the file in to File IO.
fSettings = new File(sFileName);
if (fSettings.exists() && fSettings.isFile()) {
Is it possible to load the File from classpath and Create File object? Would it be possible to validate?
Share your thoughts.
I get this following error:
22:44:16,718 ERROR [STDERR] java.io.FileNotFoundException: file:\C:\Servers\ApplicationServers\jboss-4.2.3.GA\server\XXXX\tmp\deploy\XXX.ear-contents\XXX.rar!\common.xml (The filename, directory name, or volume label syntax is incorrect)
22:44:16,718 ERROR [STDERR] at java.io.FileInputStream.open(Native Method)
The URL that you get with the
getResource()might not be a file, and in this case it’s not because yourcommon.xmlis inside of a RAR file. If you want to accesscommon.xml, just do agetResourceAsStream()and read theInputStream.