Posted By:
Madhusudhan_Rao
Posted On:
Monday, August 21, 2006 05:16 AM
Here the sample code , hope it may help
import java.net.URL;
public class FindResource {
public FindResource() {
String path = FindResource.class.getClassLoader().getResource("findfile.txt").getPath();
System.out.println(" Path :" + path);
}
public static void main(String args[]) {
new FindResource();
}
}
findfile.txt is the file whose path i want to extract.
make sure it is in the same folder where u r stroing this
java file. Or else it will throw NullPointerException
if u r using servlet , then make use of the ServletContext to find the file.