无论是maven工程还是eclipse工程,有时工程引入的jar包并不是运行是实际使用的jar,真正的jar可能是容器内部,这个这个时候如果出现依赖冲突,可以通过this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();精确获取使用运行的类,加载的位置。
分类:
编程语言 时间:
2015-05-04 22:19:47
阅读次数:
153
java中获得当前文件路径多种方法 public String getClassPath(){ String path=""; try { path=new File(getClass().getClassLoader().getResource("").toURI()).getPath(); }catch (URISyntaxException ex) {} re...
分类:
编程语言 时间:
2015-04-21 11:31:05
阅读次数:
145
String path=Parameter.class.getResource("").getPath();//得到路径//String path=Parameter.class.getResource("").toString();//这个不行,无法处理里面的空格。//System.out.pri...
分类:
编程语言 时间:
2015-04-08 21:27:24
阅读次数:
202
String baseinfo="/com/Bean/DBhelp.properties"; filename=getClass().getClassLoader().getResource("/").getPath(); filename=filename.substring(1,file...
分类:
编程语言 时间:
2015-04-08 21:21:50
阅读次数:
196
//使用IntentIntent intent = new Intent(Intent.ACTION_VIEW);//Uri mUri = Uri.parse("file://" + picFile.getPath());Android3.0以后最好不要通过该方法,存在一些小Bugintent.se...
分类:
移动开发 时间:
2015-03-30 15:50:57
阅读次数:
234
public static String DEPLOY_PATH = null;
static
{
String CurrentClassFilePath = Constant.class.getResource("").getPath();
int lastpath = CurrentClassFilePath.lastIndexOf("WEB-INF/");
DEPLOY_PA...
分类:
编程语言 时间:
2015-03-13 18:45:02
阅读次数:
146
java读取src目录下的文件,有几种方法
方法一:
Thread.currentThread().getContextClassLoader().getResourceAsStream(""); //当前线程的类加载器 同一线程不太稳定
方法二:
this.getClass().getResource("/"+path).toURI().getPath();//不会出...
分类:
编程语言 时间:
2015-03-12 15:12:10
阅读次数:
218
getClass().getClassLoader().getResource("/sy/config/sheetMonitor-config.xml").getPath().replace("%20","")
分类:
编程语言 时间:
2015-03-03 11:59:12
阅读次数:
155
例如我有一个Python程序,叫getPath.py,用来获得我选中的文件的全路径名称。
getPath.py
import sys
if __name__ == '__main__':
if len(sys.argv)!= 2:
sys.exit('argv error!')
##sys.argv[1]就是输入的带路径文件名。
##后面是对sys.a...
分类:
编程语言 时间:
2015-02-14 18:56:39
阅读次数:
473
String path = ServletDemo1.class.getClassLoader().getResource("db.properties").getPath(); //在servlet下,用ServletContext的getRealPath方法的得到资源库路...
分类:
其他好文 时间:
2015-02-10 14:57:00
阅读次数:
263