Hi All
I am trying to read a text file which is set in CLASSPATH system variable. Not a user variable.
I am trying to get input stream to the file as below:
Place the directory of file (D:\myDir
)in CLASSPATH and try below:
InputStream in = this.getClass().getClassLoader().getResourceAsStream("SomeTextFile.txt");
InputStream in = this.getClass().getClassLoader().getResourceAsStream("/SomeTextFile.txt");
InputStream in = this.getClass().getClassLoader().getResourceAsStream("//SomeTextFile.txt");
Place full path of file (D:\myDir\SomeTextFile.txt
)in CLASSPATH and try the same above 3 lines of code.
But unfortunately NONE of them are working and I am always getting null
into my InputStream in
.
Any way out please? I googled a lot and none of the websites, including Stack Overflow, has any reliable information about getResourceAsStream().
Regards
Chaitanya