读取配置参数的properties文件,路径获取问题

读取配制文件的时候,使用下面的方法,可方便获取classpath绝对路径:
Thread.currentThread().getContextClassLoader().getResource("").getPath();

        propertie = new Properties(); 
        String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();     
        try {   
        	inputFile = new FileInputStream(path + XXX.properties);   
            propertie.load(inputFile);   
            inputFile.close();   
        } catch (FileNotFoundException ex) {   
            System.out.println("文件不存在");   
            ex.printStackTrace();   
        } catch (IOException ex) {   
            System.out.println("装载文件失败");   
            ex.printStackTrace();   
        }   


你可能感兴趣的:(thread)