[JAVA] Property reading in POJO

This is a sample implementation that reads properties with POJO.

package sample;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;

public class propertyApp {

	public static void main(String[] args) throws FileNotFoundException, IOException {
		ResourceBundle rb = ResourceBundle.getBundle("sample", Locale.getDefault());
		System.out.println(rb.getString("project_id"))	;
		System.out.println(rb.getString("project_name"));
		
		Properties p = new Properties();
		p.load(new FileInputStream("resources/sample.properties"));
		System.out.println(p.getProperty("project_id"));
		System.out.println(p.getProperty("project_name"));
	}

}

Recommended Posts

Property reading in POJO
Implement writing and reading to Property List (.plist) in Swift
Reading and writing gzip files in Java