国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Java獲取Jar包路徑
http://hi.baidu.com/matrix286/blog/item/fe6d8cfbdffae915a8d311b2.html
Java獲取Jar包路徑
2010年01月09日 星期六 17:09
public class JarUtil
{
private String jarName;
private String jarPath;
public JarUtil(Class clazz)
{
String path = clazz.getProtectionDomain().getCodeSource().getLocation()
.getFile();
try
{
path = java.net.URLDecoder.decode(path, "UTF-8");
}
catch (java.io.UnsupportedEncodingException e)
{
e.printStackTrace();
}
java.io.File jarFile = new java.io.File(path);
this.jarName = jarFile.getName();
java.io.File parent = jarFile.getParentFile();
if (parent != null)
{
this.jarPath = parent.getAbsolutePath();
}
}
/**
* 獲取Class類所在Jar包的名稱
*
* @return Jar包名 (例如:C:\temp\demo.jar 則返回 demo.jar )
*/
public String getJarName()
{
try
{
return java.net.URLDecoder.decode(this.jarName, "UTF-8");
}
catch (java.io.UnsupportedEncodingException e)
{
e.printStackTrace();
}
return null;
}
/**
* 取得Class類所在的Jar包路徑
*
* @return 返回一個路徑 (例如:C:\temp\demo.jar 則返回 C:\temp )
*/
public String getJarPath()
{
try
{
return java.net.URLDecoder.decode(this.jarPath, "UTF-8");
}
catch (java.io.UnsupportedEncodingException e)
{
e.printStackTrace();
}
return null;
}
public static void main(String[] args) throws Exception
{
JarUtil ju = new JarUtil(JarUtil.class);
System.out.println("Jar name: " + ju.getJarName());
System.out.println("Jar path: " + ju.getJarPath());
}
}
(#)
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
為什么Java項(xiàng)目前會出現(xiàn)一個紅色感嘆號!
關(guān)于系統(tǒng)讀取properties配置文件的路徑問題,包括打成jar包的運(yùn)行文件
統(tǒng)計(jì)java代碼行數(shù)和jar包中*.class代碼的行數(shù)
springboot 打jar 包部署時 讀取外部配置文件
在Jar包中打入DLL文件并調(diào)用的方式
使用hadoop eclipse plugin提交Job并添加多個第三方j(luò)ar(完美版)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服