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



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. jenkins部署java项目,脚本文件放在远程仓库中 和jar一起打包(六)

    jenkins部署java项目到远程linux上,脚本文件和项目一起上传到gogs上,直接执行gogs上的脚本文件来执行项目 (1)新建maven项目 pom.xml的配置 <project x ...

  2. 每天CSS学习之white-space

    white-space是CSS的属性,其作用是规定文本不进行换行. white-space有以下几个值: 1.normal:该值为默认值,段落前后的空白会被浏览器忽略.如下所示: <div st ...

  3. [Leetcode221]最大面积 Maximal Square

    [题目] Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's a ...

  4. jq demo--横向+展开菜单,支持m站

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  5. 深入理解java虚拟机---java虚拟机内存管理(六)

    java虚拟机栈的理解 虚拟机栈就是我们所熟知的栈内存,栈内存属于线程独有的.而在栈内存中的局部变量表中存储的引用类型只是存储对象的内存地址.对象的创建在堆内存中,即对象在线程共享区中. 局部变量表: ...

  6. Linux如何从零开始搭建rsync服务器(centOS6)

    Step1:检查rsync是否已经安装 rmp -qa rsync 如果没有安装的话,通过yum install rsync -y   Step2:给rsync服务添加本地用户,用于管理本地目录. u ...

  7. mybatis学习(三)----优化Mybatis配置文件中的配置

    一.把连接数据库的配置单独放在一个properties文件中 前面我们是把数据库的连接信息放在了mybatis-config.xml中,如下: <?xml version="1.0&q ...

  8. MySQL:基础知识

    基础知识 一.软件的生命周期 软件定义 软件开发 软件使用与维护 二.数据(Data) 1.定义 描述客观事物特征或性质的某种符号,经过数字化处理存储在计算机 2.数据独立性 物理独立性:指用户的应用 ...

  9. ChinaCock界面控件介绍-CCNavigateTitle

    先看一下实际项目中的运行效果,如图,通过品牌的导航栏,显示不同品牌的商品列表. 完全基于ChinaCock控件包中CCNavigateTitle组件实现的,这是一个可视控件,从组件面板上拖放一个到Fo ...

  10. express安装中出现无此命令

    原来,最新express4.0版本中将命令工具分家出来了(项目地址:https://github.com/expressjs/generator),所以我们还需要安装一个命令工具,命令如下: 安装ex ...