Switch to full style
General Java code examples
Post a reply

simple code to read properties in java

Wed Feb 06, 2013 9:33 pm

simple code to read properties in java using System.getProperties()
java code
import java.io.FileInputStream;
import java.util.Properties;

public class PropertiesTest {
public static void main(String[] args) throws Exception {
// set up new properties object
// from file "testProp.txt"
FileInputStream propFile = new FileInputStream("testProp.txt");
Properties p = new Properties(System.getProperties());
p.load(propFile);

// set the system properties
System.setProperties(p);
// display new properties
System.getProperties().list(System.out);
}
}


File: testProp.txt :
Code:
Get=Value




Post a reply
  Related Posts  to : simple code to read properties in java
 Read your gmail using Java code     -  
 Read list of files in java I/O code     -  
 Java properties utility     -  
 Simple code for taking input from shell     -  
 Simple Text-Based RPG Java Project Help!     -  
 Read stream from URL using Java     -  
 Write and Read to File In Java Example     -  
 Read double values type from file in java     -  
 [Java][C#][Skype][WinAPI] simple plugin for Skype, sound red     -  
 links CSS properties     -