如何获取键读取系统配置文件中的特定值?

更新于
2026-10-12 11:20:30
1阅读来源:SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计142个文字,预计阅读时间需要1分钟。

如何获取键读取系统配置文件中的特定值?

javapackage com.cstor.ctape.tools;

import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.Properties;

public class ConfigureFileParse { /* 解析配置文件 */}

ConfigureFileParse.java

package com.cstor.ctape.tools; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class ConfigureFileParse { /** * 根据键读取系统配置文件中对于的值 * @param key * @return String * @throws */ public static String readValue(String key) { String filePath = Constant.ConfigureFilePath; Properties props = new Properties(); InputStream in = null; String value = null; try { in = new BufferedInputStream(new FileInputStream(filePath)); props.load(in); value = props.getProperty(key); } catch (Exception e) { } finally { try { if (in != null) { in.close(); } } catch (IOException e1) { } } return value; } }

如何获取键读取系统配置文件中的特定值?
标签:值

本文共计142个文字,预计阅读时间需要1分钟。

如何获取键读取系统配置文件中的特定值?

javapackage com.cstor.ctape.tools;

import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.Properties;

public class ConfigureFileParse { /* 解析配置文件 */}

ConfigureFileParse.java

package com.cstor.ctape.tools; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class ConfigureFileParse { /** * 根据键读取系统配置文件中对于的值 * @param key * @return String * @throws */ public static String readValue(String key) { String filePath = Constant.ConfigureFilePath; Properties props = new Properties(); InputStream in = null; String value = null; try { in = new BufferedInputStream(new FileInputStream(filePath)); props.load(in); value = props.getProperty(key); } catch (Exception e) { } finally { try { if (in != null) { in.close(); } } catch (IOException e1) { } } return value; } }

如何获取键读取系统配置文件中的特定值?
标签:值