后缀名为properties,config和xml的文件内容读取
1、先建立文件(后缀名为properties和config)
2、读取类建立
public class Read{
public static Properties properties = new Properties();
static {
tr{
properties.load(new FileReader(src/type.properties));
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args){
//方式一
String type = properties.getProperty("type");
TVFactory tvFactory = (TVFactory)Class.forName(type).newInstance();
TV tv = tvFactory.produceTV();
tv.pay();
//方式二(xml的读取)
SAXReader reader = new SAXReader();
Document document = reader.read(new File(src/tv.xml));
Element config = document.getRootElement();
Iterator it = config.elementIterator();
String str = null;
while(it.hasNext){
Element type = it.next();
str = type.getStringValue();
}
TVFactory tvFactory = (TVFactory)Class.forName(type).newInstance();
TV tv = tvFactory.produceTV();
tv.pay();
}
}
后缀名为properties,config和xml的文件内容读取的更多相关文章
- idea中maven项目xml资源文件无法读取
解决方法:编辑pom.xml文件 添加如下标签 <build> <resources> <resource> <directory>src/main/j ...
- c++源文件后缀名
C中: 头文件后缀名: .h 源文件后缀名: .c C++中: 头文件后缀名: .h, .hpp, .hxx 源文件后缀名:.cpp, .cc, .cxx, .C .c++ 现 ...
- TrueType字体的后缀名解释
OpenType标准定义了OpenType文件名称的后缀名.包含TureType字体的OpenType文件后缀名为.ttf,包含PostScript字体的文件后缀名为.OTF.如果是包含一系列True ...
- MFC 的资源文件 就是那个后缀名是 .rc的那个
参考: http://blog.csdn.net/zgrjkflmkyc/article/details/16897881 http://www.oschina.net/question/565065 ...
- C/C++获取文件后缀名并且比较
以下这段是VC中过去文件后缀名的方法 1.CString GetSuffix(CString strFileName) { return strFileName.Right(strFi ...
- c++源文件后缀名问题
VC里用cpp作后缀名, 在GCC里默认采用C.cc.cxx作为后缀名 .cpp, .h (VS file).cc, .h (GCC file) C中: 头文件后缀名: .h 源文件后缀名: .c ...
- Win10怎么批量修改文件后缀名?
Win10怎么批量修改文件后缀名?一般我们都是右击重命名,但是,如果要改的文件很多的话,这样做事不行的,该怎么批量修改后缀名呢?下面我们一起来看看两种解决办法 通常我们修改文件后缀名都是右击>& ...
- C++源文件的后缀名问题
VC里用cpp作后缀名, 在GCC里默认采用C.cc.cxx作为后缀名 .cpp, .h (VS file).cc, .h (GCC file) C中: 头文件后缀名: .h 源文件后缀名: .c ...
- Solr json,xml等文件数据导入(添加索引)linux下操作
使用solr-5.3.1\example\exampledocs下的post.jar来完成数据导入 1.将想要导入的文件放在solr-5.3.1\example\exampledocs中,如aaa.x ...
随机推荐
- Kafka入门初探+伪集群部署
Kafka是目前非常流行的消息队列中间件,常用于做普通的消息队列.网站的活性数据分析(PV.流量.点击量等).日志的搜集(对接大数据存储引擎做离线分析). 全部内容来自网络,可信度有待考证!如有问题, ...
- lua实现深度拷贝table表
lua当变量作为函数的参数进行传递时,类似的也是boolean,string,number类型的变量进行值传递.而table,function,userdata类型的变量进行引用传递.故而当table ...
- BugHD for JavaScript上线,轻松收集前端 Error
从收集 APP 崩溃信息到全面收集网站出现的 Error,现在的 BugHD 变得更加强大.目前,BugHD JS Error 收集功能 已正式上线,前端 er 们不用再面对一堆 Bug 无处下手. ...
- Python字符串的encode与decode
首先要搞清楚,字符串在Python内部的表示是unicode编码. 因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unic ...
- Warning: Null value is eliminated by an aggregate or other SET operation.
Null 值会被聚合函数忽略,默认情况下,Sql Server会给出Warning: Warning: Null value is eliminated by an aggregate or othe ...
- Spring(一)第一个示例
原文链接:http://www.orlion.ga/185/ 一.下载与安装Spring 1.访问https://repo.spring.io/webapp/#/artifacts/browse/tr ...
- mongodb-$type、limit、skip、sort方法、索引、聚合
一.$type操作符 $type操作符是基于BSON类型来检索集合中匹配的数据类型,并返回结果. MongoDB 中可以使用的类型如下表所示: 类型 数字 备注 Double 1 String 2 ...
- dpi 、 dip 、分辨率、屏幕尺寸、px、density 关系以及换算
一.基本概念 dip : Density independent pixels ,设备无关像素. dp :就是dip px : 像素 dpi :d ...
- [OpenCV] Samples 11: image sequence
一帧一帧地读取视频流. VideoCapture sequence(file_video); sequence >> image. #include <opencv2/core/co ...
- GitHub入门教程 Hello World for GitHub
Intro 1.简介 What is GitHub? 2.什么是github? Create a Reposi ...