Tag: Data return lips get bin int () point thinking think
Package unit02;/** * * @time September 18, 2014 PM 10:29:48 * @porject Thinkinginjava * @author Kiwi */public class Test03 {privat E String getpathbypoint () {return This.getclass (). getClassLoader (). GetResource ("."). GetPath ();} Private String getpathbynothing () {return This.getclass (). getClassLoader (). GetResource (""). GetPath (); Private String Getresourcepath () {return This.getclass (). GetResource (""). GetPath (); Private String Getresourcepathbypoint () {return This.getclass (). GetResource ("."). GetPath ();} Private String Getthreadpath () {return Thread.CurrentThread (). Getcontextclassloader (). GetResource (""). GetPath (); Private String Getthreadpathbypoint () {return Thread.CurrentThread (). Getcontextclassloader (). GetResource ("."). GetPath ();} public static void Main (string[] args) {Test03 test03 = new Test03 (); System.out.println ("This.getclass (). getClassLoader (). GetResource (\". \ "). GetPath () = \ n" + test03.getpathbypoint ()) ; System.out.println ("This.getclass (). getClassLoader (). getresource (\" \ "). GetPath () = \ n"+ test03.getpathbynothing ()); System.out.println ("This.getclass (). getresource (\" \ "). GetPath () = \ n" + test03.getresourcepath ()); System.out.println ("This.getclass (). GetResource (\". \ "). GetPath () = \ n" + test03.getresourcepathbypoint ()); System.out.println ("Thread.CurrentThread (). Getcontextclassloader (). getresource (\" \ "). GetPath () = \ n" + Test03.getthreadpath ()); System.out.println ("Thread.CurrentThread (). Getcontextclassloader (). GetResource (\". \ "). GetPath () = \ n" + Test03.getthreadpathbypoint ()); System.out.println (System.getproperty ("User.dir")); System.out.println (System.getproperty ("Java.class.path"));}}
Execution Result: (Note: test environment: Eclipse. Project name: Thinkinginjava; package Name: unit02)
This.getclass (). getClassLoader (). GetResource ("."). GetPath () =/f:/java/java_workspace/thinkinginjava/bin/this.getclass (). getClassLoader (). GetResource (""). GetPath ( ) =/f:/java/java_workspace/thinkinginjava/bin/this.getclass (). GetResource (""). GetPath () =/f:/java/java_workspace /thinkinginjava/bin/unit02/this.getclass (). GetResource ("."). GetPath () =/f:/java/java_workspace/thinkinginjava/bin/unit02/thread.currentthread (). GetContextClassLoader (). GetResource (""). GetPath () =/f:/java/java_workspace/thinkinginjava/bin/thread.currentthread (). Getcontextclassloader (). GetResource ("."). GetPath () =/f:/java/java_workspace/thinkinginjava/bin/f:\java\java_workspace\thinkinginjavaf:\java\java_ Workspace\thinkinginjava\bin; F:\java\java_workspace\code\mindview.jar
Java path fetch