Tuesday, 17 July 2012

Java property file example

Java program which takes the value from external files

It is stored with property file in sonuasher89 in inbox


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesClass {

public static void main(String[] args) 
{
Properties props = new Properties();
try {
props.load(new FileInputStream(new File("C:/Documents and Settings/folder/Wrk_SPS/PropertiesTest/src/sample.properties")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(props.getProperty("sample"));
}
}



No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...