0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

message.propertiesの実装メモ

0
Posted at
  • message.propertiesはsrc/main/resources直下におく
  • UTF-8でよい
  • message.propertiesの中身
E0001 = DBエラーです。システム管理者にお問い合わせください。
E0002 = 内部エラーです
  • コーディング例
import java.util.Date;
import java.util.Properties;
~~~
// message.properties ファイル
final InputStream inputStream = cmnUtil.getClass().getClassLoader()
        .getResourceAsStream("message.properties");
 
// ファイルをロードする
Properties props = new Properties();
InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8");
BufferedReader reader = new BufferedReader(isr);
props.load(reader);
 
// シンプルなメッセージ出力
System.out.println(props.getProperty("warn.1001"));
// 引数を与えてフォーマットしてメッセージ出力
System.out.println(MessageFormat.format(props.getProperty("warn.1002"),
 "8", "32"));
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?