java配置文件是什么-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
java配置文件是什么

Java中的配置文件名称一般都以“.properties”和“.xml”进行结尾,这些配置文件的结构都和Java的HashMap结构是一样的,其作用是通过修改配置文件来实现代码中的参数的更改,从而实现灵活变更参数。

成都创新互联公司于2013年成立,是专业互联网技术服务公司,拥有项目成都网站设计、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元崇州做网站,已为上家服务,为崇州各地企业和个人服务,联系电话:18980820575

properties使用

driver=com.MySQL.jdbc.Driver 
jdbcUrl=jdbc:mysql://localhost:3306/user 
user=root 
password=123456
/**
     * 读取config.properties文件中的内容,放到Properties类中
     * @param filePath 文件路径
     * @param key 配置文件中的key
     * @return 返回key对应的value
     */
    public static String readConfigFiles(String filePath,String key) {
        Properties prop = new Properties();
        try{
            InputStream inputStream = new FileInputStream(filePath);
            prop.load(inputStream);
            inputStream.close();
            return prop.getProperty(key);
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("未找到相关配置文件");
            return null;
        }
    }

xml使用



    
        cxx1
        Bob1
        stars1
        85
    
    
        cxx2
        Bob2
        stars2
        85
    
    
        cxx3
        Bob3
        stars3
        85
    
package com.cxx.xml;

import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
/**
 * @Author: cxx
 * Dom操作xml
 * @Date: 2018/5/29 20:19
 */
public class DomDemo {
    //用Element方式
    public static void element(NodeList list){
        for (int i = 0; i 

以上就是Java 中什么是配置文件的详细内容,更多请关注创新互联其它相关文章!


分享名称:java配置文件是什么
本文网址:http://scgulin.cn/article/psoejj.html