Java gets the project file path implementation method

  • 2020-04-01 02:16:15
  • OfStack

Enclosing getClass (). GetResource ("/"). GetPath (). The substring (1) get the path for E: / myeclipse/test/WebRoot/WEB - INF/classes /, namely home directory.

Enclosing getClass (). GetResource (" "). GetPath (). The substring (1) get the path for E: / myeclipse/test/WebRoot/WEB - INF/classes/net/hncu/db /, namely the relative path of this file.

This.getclass ().getresource (".").getpath ().substring(1) is the same as this.getclass ().getresource ("").getpath ().substring(1)


Related articles: