eclipse配置文件的创建及读取

1.配置文件的创建
2.配置文件的创建

public static void main(String[] args) {
		// TODO 自动生成的方法存根
		
		 String path = System.getProperty("user.dir");  //获取项目路径
			String filePath=path+"/src/s.properties";  		//拼串
		InputStream is = null;
		Properties prop=new Properties();
			try {
				is = new FileInputStream(filePath);
				prop.load(is);
			} catch (FileNotFoundException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			} catch (IOException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
		
			System.out.println(prop.getProperty("a"));
		 
	}
发布了179 篇原创文章 · 获赞 17 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/feiqipengcheng/article/details/105549524