「Java」java.util.ListResourceBundle.getContents() の使い方
サンプルコード
package itstudy;
import java.util.ListResourceBundle;
// create a class that extends to ListResourceBundle
class CftResources extends ListResourceBundle {
// get contents must be implemented
protected Object[][] getContents() {
return new Object[][]{
{“travel", “日本旅行!"},
{“server", “Linux Windowsサーバ!"},
{“language", “英語 日本語 中国語"}
};
}
}
public class ListResourceBundlegetContentsDemo {
public static void main(String[] args) {
// create a new CftResources instance
CftResources mr = new CftResources ();
// print the string for key travel
System.out.println(“" + mr.getString(“travel"));
}
}
実行結果
日本旅行!