bat读配置文件*.properties
来源:互联网 发布:在淘宝怎么开店铺 编辑:程序博客网 时间:2024/06/06 02:40
原文地址:http://michael-paul.iteye.com/blog/740000
i want to read a below property file and get the particular key value
My properties file look like
name=arulraj.net version=1.0.2 date=24/March/2010
I want get the version from the properties file. you can do this by various method.
Using Type function:
C:\Users\Arul\Desktop>type test.properties | find “version”
There is disadvantage with this method you could not store that value in a variable.
Using For Loop:
C:\Users\Arul\Desktop>FOR /F %i IN (test.properties) DO echo %i
using this command you can read that file by line by line.
FOR /F “eol=; tokens=2,2 delims==” %i IN (test.properties) DO echo %i
Using this commend you can get the values only.
eol is End of Line
tokens is specify the which tokens are displayed – 2,2 means only the second token will be displayed
delims is the deliminator . this is the separator
FOR /F "eol=; tokens=2,2 delims==" %i IN ('findstr /i "version" test.properties') DO set version=%i
Using findstr get the correct string from the properties file and give as a input to the for loop. That for loop process the result and set that value to the variable version.
findstr /i means is not a case sensitive one
using echo you can get the value.
echo %version%
When you using in a bat add a % befor %i. That is Look like
FOR /F "eol=; tokens=2,2 delims==" %%i IN ('findstr /i "version" test.properties') DO set version=%%i echo %version%
- bat读配置文件*.properties
- 读配置文件properties
- 读配置文件(properties)ConfigFileUtils
- 读配置文件 properties
- [Properties]——读配置文件
- Properties配置文件
- Properties配置文件
- Properties配置文件
- properties配置文件
- Properties配置文件
- properties配置文件
- Properties类读写.properties配置文件
- bat生成配置文件
- bat脚本读取配置文件
- Bat 修改配置文件版本
- struts.properties配置文件详解
- struts.properties配置文件
- java 读取properties配置文件
- 基本数据类型 Int、Double、Float
- 移除 URL 中的 index.php
- 用 WEKA 进行数据挖掘,第 1 部分: 简介和回归
- iOS 如何调试第三方统计到的崩溃报告
- js动态引用一个或多个CSS样式
- bat读配置文件*.properties
- playframework 模板工程
- 算法分析:方阵的主对角线之上称为“上三角”。
- 考研攻略-以此鞭策自己
- C++确定常量的数据类型
- DES+Base64 加密、解密详情
- ecshop 权限系统设计原理分析。
- 策略模式
- Git使用教程