LoginSignup
2
2

More than 5 years have passed since last update.

commons-configurationでUTF-8を使う場合のコード例

Posted at

大したことじゃないけど、メモを残す意味で記述

バージョン

  • commons-configuratin : 1.10

コード

java
PropertiesConfiguration config = new PropertiesConfiguration();
config.setEncoding("UTF-8");
config.setFile([プロパティファイル]);
config.load();

PropertiesConfigurationのコンストラクタでnew PropertiesConfiguration(File file)があって、
これを使うとnewしただけでsetFile(File file)load()をやってくれるが、
setEncoding(String encoding)で指定したエンコーディングが効かないので個別に指定する。

UTF-8に限らず、デフォルトのエンコーディング(ISO-8859-1)以外を指定する場合はこの対応が必要。

2
2
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
2
2