Package IO;
Import java.net.URL;
/ **
*
Title: The relative path where the current file is located and the absolute path is located P>
*
*
Description: The relative path where the current file is located in the class and the absolute path P>
*
*
Copyright: Copyright (c) 1997 - 2005 P>
*
*
Company: beyond daybreak office p>
*
* @AuThor Yulimin
* @version 1.0
* /
Public Class getClassPath
{
Public getClassPath ()
{
Super ();
}
/ **
* main
*
* @Param args string []
* /
Public static void main (string [] args)
{
GetClassPath getClassPath = new getclasspath ();
System.out.println (GetClassPath.getClassPath ());
}
/ **
* The relative path to the current file is located in the class and the absolute path
*
* @Return String
* /
Public string getclasspath ()
{
String strclassname = getclass (). Getname ();
String strpackagename = ""
IF (getClass (). getpackage ()! = null)
{
StrPackageName = getClass (). getName (); GetName ();
}
System.out.println ("ClassName: StrClassName);
System.out.println ("PackageName: StrPackageName);
String strclassFilename = "";
IF (! ". Equals (strpackagename))
{
STRCLASSFILENAME = STRCLASSNAME.SUBSTRING (STRPACKENAME.LENGTH () 1, STRCLASSNAME.LENGTH ());
}
Else
{
STRCLASSFILENAME = STRCLASSNAME;
}
System.out.println ("ClassFileName:" STRCLASSFILENAME);
URL URL = NULL;
URL = getClass (). getresource (strclassfilename ".class");
Strincel = url.tostring ();
Strurl = Strurl.substring (Strull.IndexOf ('/') 1, Strurl.lastIndexOf ('/'));
Return Strurl;
}
}