项目的结构:相同颜色是同级的



bean的配置文件的读取和一般文件的读取有点差别的

    public static void getValue(String key){ //传入"time"
Properties prop = new Properties();
Properties prop2 = new Properties();
Properties prop3 = new Properties();
//要么是全路径
File file = new File("D:\\java\\content\\eclipse-win64\\S\\java\\fd.properties");
     //要么是去在全路径基础上去掉项目名
File file2 = new File("java\\fd.properties");
File file3 = new File("fd2.properties");
try {
//装载配置文件
prop.load(new FileInputStream(file));
prop2.load(new FileInputStream(file2));
prop3.load(new FileInputStream(file3)); } catch (IOException e) {
e.printStackTrace();
}
//返回获取的值
System.out.println(prop.getProperty(key)
+ prop2.getProperty(key)+prop3.getProperty(key));
}
8 8 9




fd.properties的内容

项目名是 S

  

点开bin文件夹

注意这个fd.properties文件

发现:

只有在src或者java文件夹下的java文件或资源文件才会编译,然后通过打包,会复制到commlib中


后面有2个ok

	/*
1.绝对路径 a.带盘符,如E:/book.xml b.以http开头,http://img.baidu.com/img/book.jpg 2.相对路径 a.带"/"开头,如/book.xml b.不带"/"开头,如book.xml 现在项目结构如下,在ParseXML类中操作,我实验项目System.getProperty("user.dir")=E:\ProjectTest\javaEE\ 绝对路径: new
File("E:/ProjectTest/javaEE/src/com/ly/javaee/xml/dom4j/book.xml")---OK 相对路径 new
File("book.xml")----报错(此时相当于System.getProperty("user.dir")+"book.xml",这是文件book.xml不存在user.dir下面) new File("src/com/ly/javaee/xml/dom4j/book.xml")----OK(不带"/"
可见在项目中相对的是以项目名为根路径,此时相当于System.getProperty("user.dir")+"src/com/ly/javaee/xml/dom4j/book.xml") new File("/book.xml")----以下可以看出本JVM运行在E盘下,此时带"/"就相当于"E:/book.xml",JVM运行在哪个盘符就以哪个为根路径 new
File("./book.xml");---报错(同new File("book.xml")效果)

  

File file = new File("路径名") 路径名的2种写法的更多相关文章

  1. 【翻译自mos文章】对于每个文件的 file.id and file.incarnation number,重命名文件别名

    对于每个文件的 file.id and file.incarnation number,重命名文件别名 參考原文: Rename Alias of Datafile as Per file.id an ...

  2. File.createNewFile和 File.createTempFile比较和区别

    原文地址:http://wzhiju.iteye.com/blog/1119037 最近,在看代码时看到了一个方法, File.createTempFile() ,由此联想到File.createNe ...

  3. python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory

    安装python3遇到报错: wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz ./configure --prefix=/u ...

  4. 安卓开发error opening trace file: No such file or directory (2)报错原因

    error opening trace file: No such file or directory (2) 这个问题的出现是因为运行的测试机android系统版本和项目api不一致导致. 改成一样 ...

  5. error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

    zabbix3.2启动有如下报错: # service zabbix_server startStarting zabbix_server:  /home/zabbix-server/sbin/zab ...

  6. 错误解决:error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory

    执行以下代码,生成唯一的UID $fp = popen("/xxx/bin/tools/uuidgen system", "r");// $uid = frea ...

  7. 【转】error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

    错误信息: /usr/local/memcacheq/bin/memcacheq: error while loading shared libraries: libevent-2.0.so.5: c ...

  8. 解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误

    问题 在Centos7上编译安装openssl后,运行openssl version出现如下错误: openssl: error while loading shared libraries: lib ...

  9. NopCommerce 发布时 Could not load file or assembly 'file:///...\Autofac.3.5.2\lib\net40\Autofac.dll' or one of its dependencies

    本文转自:http://www.nopcommerce.com/boards/t/33637/4-errors.aspx 问题: The 3.5 solution compiles fine, and ...

随机推荐

  1. day24 模块03_re

    休养生息 --模块03 1.正则表达式 2.在python中使用正则.re 一,正则表达式 (匹配字符串,主要是给字符串使用的) 1)元字符 .  除换行符之外 \w 数字,字母,下划线组成   \W ...

  2. libiconv库的安装和使用

    1.libiconv包的下载路径 包的下载页面http://www.gnu.org/software/libiconv/ 2.编译安装libiconv库 $tar zxvf libiconv-1.14 ...

  3. C/C++知识补充(2) C/C++操作符/运算符的优先级 & 结合性

    , 逗号操作符 for( i = 0, j = 0; i < 10; i++, j++ ) ... 从左到右   Precedence Operator Description Example ...

  4. tp配置

    <?php// +----------------------------------------------------------------------// | ThinkPHP [ WE ...

  5. SQL-17 获取当前(to_date='9999-01-01')薪水第二多的员工的emp_no以及其对应的薪水salary

    题目描述 获取当前(to_date='9999-01-01')薪水第二多的员工的emp_no以及其对应的薪水salaryCREATE TABLE `salaries` (`emp_no` int(11 ...

  6. freemarker学习 (servlet + freemarker -> Struts2+freemarker -> springMVC+freemarker)

    什么是freemarker? freemarker类似于jsp,但不是jsp!怎么说呢?freemarker文件后缀是.ftl,它不像jsp本质是servlet,它将构建模板.解析模板.使用模板分离开 ...

  7. springMvc 简单搭建

    1.pom.xml 依赖引入 2.配置web.xml 3.配置 springMvc.xml 4.配置 logback.xml 5.编写 controller 测试 1.pom.xml 依赖引入 < ...

  8. quartz自定义线程数

    1.加载包 2.添加quartz.propertes 3.编写自己的任务类 4.添加自动任务配置 5.通过 quartzProperties 配置连接池 1.加载包 <dependency> ...

  9. pthread库实现一个简单的任务池

    pthread库实现一个简单的任务池 类关系图: 说明:         1:TaskManager类管理Task类,Task类是一个纯虚类;         2:ThreadManager类管理Th ...

  10. Python中常见字符串去除空格的方法总结

    Python中常见字符串去除空格的方法总结 1:strip()方法,去除字符串开头或者结尾的空格>>> a = " a b c ">>> a.s ...