0
点赞
收藏
分享

微信扫一扫

ClassLoader.getResourceAsStream(name); ---java读取配置文件

GhostInMatrix 2022-03-30 阅读 46
mysqljava


package com.bll.mysql;

import java.io.InputStream;
import java.util.Properties;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
try {
InputStream res= App.class.getClassLoader().getResourceAsStream("1.txt");
Properties prop = new Properties();
prop.load(res);
String string = prop.getProperty("className");
System.out.println(string);


} catch (Exception e) {
// TODO: handle exception
}
System.out.println( "Hello World!" );
}
}



1.txt内容

className = com.mysql.jdbc.Driver

url=jdbc:mysql


举报

相关推荐

0 条评论