Java Class getResource() MethodThe getResource() method of java Class class is used to return the resources of the module in which this class exists. The value returned from this function exists in the form of the object of the URL class. SyntaxParametername - the name of the desired resource ReturnsA URL object. ThrowsNullPointerException Example 1Test it NowOutput: Value URL = null Value URL = file:/C:/Users/Suman/Documents/NetBeansProjects/calendar/build/classes/Class/file1.txt Example 2Test it NowOutput: Value URL = file:/C:/Users/Suman/Documents/NetBeansProjects/calendar/build/classes/Class/file1.txt Value URL = file:/C:/Users/Suman/Documents/NetBeansProjects/calendar/build/classes/Class/newfolder/file2.txt
Next TopicJava Class
|