Total Pageviews

2015/10/16

[Java] Read properties file in java with new line characters in values

Requirement
If I would like to read property file, and I hope some characters will print in new line as expected. 

How-to
You can add \n \ as the end of each line
Here is the property file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
dbm.getPredictedNumber=with predictedNumber as ( \n \
SELECT lpad(to_char(a.ACCOUNT_YR, 'yyyy')-1911, 3, '0') AS ACCOUNT_YR, \n \
       a.BUDGET_STATUS AS BUDGET_STATUS, \n \
       a.BUDGET_CODE AS BUDGET_CODE, \n \
       a.DEBT_CODE AS DEBT_CODE, \n \
       a.DATA_TYPE AS DATA_TYPE, \n \
       b.DEBT_TYPE AS DEBT_TYPE, \n \
       b.BOND_TYPE AS BOND_TYPE, \n \
       nvl(b.ALLC_AMOUNT, 0) AS ALLC_AMOUNT \n \
FROM \n \
  (SELECT ACCOUNT_YR, \n \
          BUDGET_CODE, \n \
          DEBT_CODE, \n \
          DATA_TYPE, \n \
          BUDGET_STATUS, \n \
          END_DATE, \n \
          MAX(BUDGET_STATUS) OVER (PARTITION BY ACCOUNT_YR, BUDGET_CODE, DEBT_CODE, DATA_TYPE, SUBSTR(BUDGET_STATUS, 0, 1)) AS maxBudgetStatus \n \
   FROM DBM091FA \n \
   WHERE DATA_TYPE IN ('C', \n \
                       'I')) a, \n \


The output:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
DEBUG c.c.c.persistence.query.SqlExecutor - Executing SQL:with predictedNumber as ( 
SELECT lpad(to_char(a.ACCOUNT_YR, 'yyyy')-1911, 3, '0') AS ACCOUNT_YR, 
a.BUDGET_STATUS AS BUDGET_STATUS, 
a.BUDGET_CODE AS BUDGET_CODE, 
a.DEBT_CODE AS DEBT_CODE, 
a.DATA_TYPE AS DATA_TYPE, 
b.DEBT_TYPE AS DEBT_TYPE, 
b.BOND_TYPE AS BOND_TYPE, 
nvl(b.ALLC_AMOUNT, 0) AS ALLC_AMOUNT 
FROM 
(SELECT ACCOUNT_YR, 
BUDGET_CODE, 
DEBT_CODE, 
DATA_TYPE, 
BUDGET_STATUS, 
END_DATE, 
MAX(BUDGET_STATUS) OVER (PARTITION BY ACCOUNT_YR, BUDGET_CODE, DEBT_CODE, DATA_TYPE, SUBSTR(BUDGET_STATUS, 0, 1)) AS maxBudgetStatus 
FROM DBM091FA 
WHERE DATA_TYPE IN ('C', 
'I')) a, 


Reference
[1] http://www.rgagnon.com/javadetails/java-0503.html

No comments: