I have a properties file located %ilmhome%\webapp\WEB-INF\amhome.properties
#Tue Feb 15 19:27:14 IST 2开发者_如何学C011
amhome.connection.password=amhome534
amhome.connection.url=jdbc\:oracle\:thin\:@(DESCRIPTION\=(ADDRESS_LIST\=(ADDRESS\=(PROTOCOL\=TCP)(HOST\=diablo)(PORT\=1521)))(CONNECT_DATA\=(SERVER\=DEDICATED)(SERVICE_NAME\=orcl)))
amhome.connection.maxWait=20000
amhome.connection.username=amhome534
amhome.connection.platformId=6
amhome.connection.driver_class=oracle.jdbc.driver.OracleDriver
I want to fetch the below items from amhome.properties file into some variables
Username : amhome534
Host : diablo
Port : 1521
ServiceName : orcl
ConnString : jdbc\:oracle\:thin\:@(DESCRIPTION\=(ADDRESS_LIST\=(ADDRESS\=(PROTOCOL\=TCP)(HOST\=diablo)(PORT\=1521)))(CONNECT_DATA\=(SERVER\=DEDICATED)(SERVICE_NAME\=orcl)))
How can i do that?
Check out the FOR /F command... You should be able to set DELIMS=.=
and TOKENS=3,*
which would skip 'amhome' and 'connection' but give you value pairs like 'password' + 'amhome534'.
精彩评论