Java获取路径(getResource)
package com.zhi.test;
public class PathTest {
public static void main(String[] args) {
System.out.println(PathTest.class.getResource(""));
System.out.println(PathTest.class.getResource("/"));
System.out.println(PathTest.class.getClassLoader().getResource(""));
System.out.println(PathTest.class.getClassLoader().getResource("/"));
System.out.println(ClassLoader.getSystemResource(""));
System.out.println(ClassLoader.getSystemResource("/"));
System.out.println(System.getProperty("user.dir"));
}
}
对应数据的路径如下:
file:/E:/workspace/javaee/test/target/test-classes/com/zhi/exportword/
file:/E:/workspace/javaee/test/target/test-classes/
file:/E:/workspace/javaee/test/target/test-classes/
null
file:/E:/workspace/javaee/test/target/test-classes/
null
E:\workspace\javaee\test
Java获取路径(getResource)的更多相关文章
- Java获取路径方法&相对路径读取xml文件方法
(1).request.getRealPath("/");//不推荐使用获取工程的根路径 (2).request.getRealPath(request.getRequestURI ...
- java 获取路径的各种方法
(1).request.getRealPath("/");//不推荐使用获取工程的根路径 (2).request.getRealPath(request.getRequestURI ...
- java ----获取路径的各种方法(总结)
Java Web开发中路径问题小结 (1) Web开发中路径的几个基本概念 假设在浏览器中访问了如下的页面,如图1所示: 那么针对这个站点的几个基本概念表述如下: 1. web站点的根目录:http: ...
- 【转载】java 获取路径的各种方法
转载只供个人学习参考,查看请前往原出处:http://www.cnblogs.com/guoyuqiangf8/p/3506768.html 主要方法有: (1).request.getRealPat ...
- Java获取路径中的文件名(正则表达式)
Java获取路径中的文件名(正则表达式) 目标 在这个路径中我想得到model2 /E:/2017-02-21--SoftWare/github/test/Java/poiDemo_word2exce ...
- Java获取路径的方法分析详解(Application/Web)
1.利用System.getProperty()函数获取当前路径: System.getProperty("user.dir");//user.dir用户当前的工作目录,输出:D: ...
- java获取路径的方法
package com.zjf; import java.io.File; public class GetPath { public static void getPath() { //方式一 Sy ...
- java获取路径(转)
1.利用System.getProperty()函数获取当前路径:System.out.println(System.getProperty("user.dir"));//user ...
- Java 获取路径的几种方法 - 转载
1.获取当前类所在的“项目名路径” String rootPath = System.getProperty("user.dir"); 2.获取编译文件“jar包路径”(反射) S ...
随机推荐
- CSS3实现鼠标移动到图片上图片变大(缓慢变大,有过渡效果,放大的过程是有动画过渡的,这个过渡的时间可以自定义)
转载自:http://blog.csdn.net/u014175572/article/details/51535768 CSS3的transform:scale()可以实现按比例放大或者缩小功能. ...
- AFM(3)---Maude使用说明
load file-name 1可用绝对路径 2.可进入maude文件所在目录下load 3.默认工作空间是什么?
- 哨兵查找法(明解c语言) + 函数式宏
//哨兵法,就是将待查找的元素加入待查找的数组的后面,这样可以提高性能(在数据量很庞大的时候体现出来) #include <stdio.h> #define FAILURE -1 //使用 ...
- QTableWidget自定义表头QHeaderView加全选复选框
1 QTableWidget自定义表头QHeaderView加全选复选框 在使用QTableWidget时需要在表头添加全选复选框,但是默认的表头无法添加复选框,只能用图片画上去一个复 ...
- python 多进程和多线程
在计算大量数据时,可以使用多进程 多线程机制来加速计算 多进程 import multiprocessing import os def run_proc(name): print('Child pr ...
- Jmeter 接口测试知识梳理——持续集成篇
Jmeter 使用也有很长时间了,但是一直没有做一下知识梳理,近期会对公司同事做一下这方面的培训,借此机会,把使用过程中应用到的知识,或是遇到的问题,整理出来,方便大家学习! Jmeter + Ant ...
- eclipse报错:Could not resolve bean definition resource pattern [classpath:spring/applicationContext-*.xml]或者找不到
1.把xml文件复制到WEB-INF下 2.路径改成 [/WEB-INF/spring/applicationContext-*.xml]
- learn the python the hard way习题26~30总结
考试试题26错误总结: 漏写字母,括号 写错字母 write(),read()的使用:只能打开使用了 open() 后返回的文件对象(file object),而不能直接使用文件名 if 语句中,条件 ...
- You Don't Know JS: Scope & Closures (第2章: Lexical Scope)
2种主要的models for how scope work. 最普遍的是Lexical Scope. 另一种 Dynamic Scope.(在Appendix a中介绍.和Lexical Scope ...
- Amaze UI——slider的参数说明
<script type="text/javascript"> $(function(){ $('.am-slider').flexslider({ playAfter ...