Pages

Monday, December 26, 2011

Create Properties File

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

public class javaPro {
  
    public static void main( String[] args )
    {
        Properties prop = new Properties();

        try {
            //set the properties value
            prop.setProperty("host_name", "localhost");
            prop.setProperty("user_id", "as400");
            prop.setProperty("bpassword", "samplecode");

            //save properties to project root folder
            prop.store(new FileOutputStream("src/properties/myjdbc.properties"), null);

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

}

No comments:

Post a Comment