Pergunta de entrevista da empresa CGI

how to read key value pair from property file

Resposta da entrevista

Sigiloso

23 de mar. de 2016

public class ReadPropertiesFile { public static void main(String[] args) { // TODO Auto-generated method stub try { Properties props = new Properties(); String file="cgi.properties"; InputStream is = ReadPropertiesFile.class.getResourceAsStream("cgi.properties"); props.load(is); System.out.println(props.getProperty("company_name")); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }