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



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. 解决WDCP3环境gbk网站编码程序乱码问题

    因为默认WDCP V3版本环境编码格式是UTF-8版本,如果我们程序采用的是GBK编码肯定都会有乱码问题. 我们到WDCP后台,"网站管理"-"PHP设置",看 ...

  2. svn服务器搭建及使用(二)

    上一篇介绍了VisualSVN Server和TortoiseSVN的下载,安装,汉化.这篇介绍一下如何使用VisualSVN Server建立版本库,以及TortoiseSVN的使用. 首先打开Vi ...

  3. 【转载】Maven中的BOM概念

    1.概述 1.1.什么是 BOM? BOM stands for Bill Of Materials. A BOM is a special kind of POM that is used to c ...

  4. 十一. Python基础(11)—补充: 作用域 & 装饰器

    十一. Python基础(11)-补充: 作用域 & 装饰器 1 ● Python的作用域补遗 在C/C++等语言中, if语句等控制结构(control structure)会产生新的作用域 ...

  5. Java基础知识补充

    基础知识总结: 学习了一段时间,重新看了孤傲苍狼的博客,对一些知识有了新的理解. unicode: 全球的文字放到计算机里面表示全是0和1,Unicode是统一了全世界国家文字的一种编码方式,用这样的 ...

  6. 通过泛型获得继承类的类原型getGenericSuperclass

    首先贴上代码 package com; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; /** * ...

  7. 堆排序python实现

    def MAX_Heapify(heap,HeapSize,root):#在堆中做结构调整使得父节点的值大于子节点 left = 2*root+1 right = left + 1 larger = ...

  8. 【转】strmbasd.lib(dllentry.obj) : error LNK2001: 无法解析的外部符号"int g_cTemplates"

    加入了DirectShow的基类链接库后,如果此时编译就会出现以下编译错误: strmbasd.lib(wxutil.obj) : error LNK2019: 无法解析的外部符号 __imp__ti ...

  9. jetty域证书更新

    服务器:centos6.6 1.从正确的.pfx文件中导出.pem认证文件 #openssl pkcs12 -in example.pfx -nodes -out server.pem pfx文件可以 ...

  10. apache ab 压力测试工具

    Apache的ab命令模拟多线程并发请求,测试服务器负载压力,也可以测试nginx.lighthttp.IIS等其它Web服务器的压力.Apache附带的ab工具(使用的PHP环境是WAMP集成环境, ...