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



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. git-github-TortoiseGit综合使用教程(一)简介

    简介: 本系列教程将参考廖雪峰的git系列教程,使用github的web界面,和TortoiseGit图形界面windows程序来实现. git 是什么: Git是目前世界上最先进的分布式版本控制系统 ...

  2. ORM版学员管理系统1

    ORM版学员管理系统 班级表 表结构 class Class(models.Model): id = models.AutoField(primary_key=True) # 主键 cname = m ...

  3. 十九. Python基础(19)--异常

    十九. Python基础(19)--异常 1 ● 捕获异常 if VS异常处理: if是预防异常出现, 异常处理是处理异常出现 异常处理一般格式: try:     <............. ...

  4. [leetcode整理]

    =======简单 leetcode164 Maximum Gap sort两次 =======有参考 330 Patching Array 98 Validate Binary Search Tre ...

  5. :模板方法模式:Beverage

    #ifndef __COFFINEBEVERAGE_H__ #define __COFFINEBEVERAGE_H__ #include <iostream> using namespac ...

  6. Java的file类

    package IO; import java.io.File; import java.io.IOException; public class FileDemo01 { public static ...

  7. ios 第4天

    dealloc method  会在对象释放前调用这个方法(函数)  可以让对象在释放前把一些自己申请的对象 先释放了    满足 谁申请  谁释放 的原则 例如    dealloc 会自动调用   ...

  8. 90%会搞错的JavaScript闭包问题

    由工作中演变而来的面试题 这是一个我工作当中的遇到的一个问题,似乎很有趣,就当做了一道题去面试,发现几乎没人能全部答对并说出原因,遂拿出来聊一聊吧. 先看题目代码: function fun(n,o) ...

  9. leetcode31题:下一个排列

    实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列. 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列). 必须原地修改,只允许使用额外常数空间. ...

  10. 利用python实现电影推荐

    "协同过滤"是推荐系统中的常用技术,按照分析维度的不同可实现"基于用户"和"基于产品"的推荐. 以下是利用python实现电影推荐的具体方法 ...