Results 1 to 1 of 1
-
Initializing property object from a file
Sometimes, properties are stored in a file and you have to initialize property object from that file. Following code does exactly that:
Java Code:import java.io.FileInputStream; import java.util.Properties; class PropertiesTest { public static void main(String args[]) { try { // set up new properties object from file "myProperties.txt" FileInputStream propFile = new FileInputStream("myProperties.txt"); Properties p = new Properties(System.getProperties()); p.load(propFile); // set the system properties System.setProperties(p); System.getProperties().list(System.out); } catch (java.io.FileNotFoundException e) { ; } catch (java.io.IOException e) { ; } } }
Similar Threads
-
How to extracts a java bean object from the XML file
By Java Tip in forum java.ioReplies: 1Last Post: 01-29-2009, 09:33 AM -
How to store property file into key value pair
By Java Tip in forum java.utilReplies: 0Last Post: 04-05-2008, 10:16 AM -
Creating a File object in Servlet
By Java Tip in forum Java TipReplies: 0Last Post: 01-16-2008, 10:24 AM -
Property File
By Peter in forum JDBCReplies: 2Last Post: 07-04-2007, 03:48 PM -
log4j property file in my application
By Peter in forum Advanced JavaReplies: 3Last Post: 06-14-2007, 03:12 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks