Here you can find the source of loadConfFile(String filename, String key)
public static String loadConfFile(String filename, String key)
//package com.java2s; /**//ww w.ja va 2 s. c o m * @(#)FileUtils.java, 2014?9?15?. Copyright 2014 Yodao, Inc. All rights * reserved. YODAO PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String loadConfFile(String filename, String key) { BufferedReader fread = null; try { fread = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF-8")); String line; while ((line = fread.readLine()) != null) { if (line.startsWith("#")) continue; if (line.startsWith(key + "=")) return line.substring(line.indexOf('=') + 1); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (fread != null) fread.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } }