java读取配置文件

 

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

public class DataFilter {
    public static void main(String[] args) {    
         Properties prop = new Properties(); 
            InputStream in = Object.class.getResourceAsStream("/config/ProjectConfig.properties"); 
            try { 
                prop.load(in); 
                String host=prop.getProperty("cdma_host").trim(); 
                String user=prop.getProperty("cdma_user").trim(); 
                String passwd=prop.getProperty("cdma_passwd").trim();
                System.out.println("host:"+host+" user:"+user+" passwd:"+passwd);
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
    }
}

 

你可能感兴趣的:(读取配置文件)