读取文件信息
来源:互联网 发布:js中addeventlistener 编辑:程序博客网 时间:2024/05/21 17:51
package psic;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
public class ClientConf
{
private String CONFIG_PATH;
public ClientConf()
{
CONFIG_PATH = "";
String Os_Name = System.getProperty("os.name").toLowerCase();
String File_Sep = System.getProperty("file.separator");
if(Os_Name.indexOf("win") != -1)
CONFIG_PATH = "C:" + File_Sep + "Config" + File_Sep + "Client.conf";
if(Os_Name.indexOf("linux") != -1 || Os_Name.indexOf("unix") != -1)
CONFIG_PATH = File_Sep + "usr" + File_Sep + "local" + File_Sep + "Config" + File_Sep + "Client.conf";
}
public String getParamValue(String paramName)
{
byte buf[] = new byte[1024];
String paramValue;
try
{
ByteArrayOutputStream b_out = new ByteArrayOutputStream();
FileInputStream fin = new FileInputStream(CONFIG_PATH);
int i;
while((i = fin.read(buf, 0, buf.length)) != -1)
{
b_out.write(buf, 0, i);
b_out.flush();
}
String fileBuffer = b_out.toString().trim();
b_out.close();
fin.close();
int index1 = fileBuffer.indexOf("<" + paramName + ">");
int index2 = fileBuffer.indexOf("</" + paramName + ">");
paramValue = fileBuffer.substring(index1 + (new String("<" + paramName + ">")).length(), index2);
}
catch(Exception exception)
{
return null;
}
return paramValue;
}
- 读取文件信息
- 读取剪贴板文件信息
- 读取文件信息
- 读取Properties文件信息
- 读取properties文件信息
- C#读取文件信息
- 读取XML文件信息
- 读取txt 文件信息
- Java 读取 Properties文件信息
- 读取设备信息到文件
- spring读取properties文件信息
- 使用流读取文件信息
- php读取mp3文件信息
- 读取wmv文件时长信息
- 读取EXE文件的版本信息
- 从文件中读取security信息
- 从文件中读取文本信息
- 读取wmv文件时长信息
- 开始我的blog
- 大学的最后一个寒假
- apache+Tomcat负载平衡设置详解
- 利用ASP.NET构建网上考试系统
- 温故知新:W3C发布10个XML规范草案 网络成全球数据库
- 读取文件信息
- jabber使我认识ant
- Choosing a DOCTYPE
- 在编写和发布Java应用程序中多做考虑,改善用户体验
- 什么是WEB2.0?
- Apache的配置
- Wicket与Struts两个框架比较
- Apache中的环形链表
- Linux下的WebLogic安装部署