Recently, I want to save the configuration in XML because I wrote something. But how can I find the XML? I read jwhich and wrote a small function to find the path of the resource file. (I don't know if it is suitable for all situations. If there is something wrong, please point it out)
/**
* If no value is found, null is returned.
* @ Param sresourcename
* @ Return
*/
Public static string getresourcefilepath (string sresourcename)
{
If (! Sresourcename. startswith ("/"))
{
Sresourcename = "/" + sresourcename;
} Java.net. url classurl = jwhichutil. Class. getresource (sresourcename); If (classurl = NULL)
{
System. Out. println ("/nresource" + sresourcename + "'Not found in/N '"
+ System. getproperty ("Java. Class. Path") + "'");
Return NULL;
}
Else
{
System. Out. println ("/nresource" + sresourcename + "'found in/N'" + classurl. GetFile () + "'");
Return classurl. GetFile ();
}}