プロパティの読み込みと、MessageFormatのプレースホルダを使うことで実現はできます。
java
1import java.io.IOException;
2import java.io.InputStream;
3import java.io.InputStreamReader;
4import java.text.MessageFormat;
5import java.util.Properties;
6
7810
11public class MessagePropertiesReader {
12
13 public String getMessage() throws IOException {
14 InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("message.properties");
15 InputStreamReader reader = new InputStreamReader(inputStream, "utf8");
16 Properties properties = new Properties();
17 properties.load(reader);
18
19 String command = properties.getProperty("command");
20
21 return MessageFormat.format(command, "/usr/local/bin");
22 }
23}
ただしプロパティファイル中にあるシングルクォートで囲まれた文字列の中身は、そのまま出力してしまいますので、以下のように書き換える必要があります。
properties
1command=COPY テーブル名 TO {0}/ファイル名.tsv WITH CSV NULL AS 'null' DELIMITER E'\t' ;
実行結果は次のようになります。
COPY テーブル名 TO /usr/local/bin/ファイル名.tsv WITH CSV NULL AS null DELIMITER E ;
プレースホルダは複数の変数を指定可能です。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/12 02:53
2019/01/15 02:38 編集
2019/01/15 11:40
2019/01/17 02:26
2019/01/20 15:24