@634

java.util.ResourceBundle

Advertisement

説明。

プロパティーファイルからの値の読み込みを行う。
java.util.ResourceBundle(リンク先:java.sun.com)

実験

import java.util.ResourceBundle;

public class ResourceBundleSample{
    public static void main(String args[]){
        String name = null;
        String age = null;

        // profile.properties ファイルを読み込む
        ResourceBundle resource = ResourceBundle.getBundle("profile");

        // 値の取得
        name = resource.getString("name");
        age = resource.getString("age");

        System.out.println(name + ":" + age);
   }
}

test.properties ファイル
name=tarou
age=50
実行結果サンプル
tarou:50

Advertisement

ショートカット

634
このカテゴリのトップページに戻る
634labs
   UIコレクションギャラリー

サイト検索

Google

Web サイト内

Y!ログール