Java BufferedReader Read loadConfFile(String filename, String key)

Here you can find the source of loadConfFile(String filename, String key)

Description

load Conf File

License

Open Source License

Declaration

public static String loadConfFile(String filename, String key) 

Method Source Code

//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;
    }
}

Related

  1. loadBlackList(String blackListPath)
  2. loadBussinessGroupCompanies(String file_path)
  3. loadByUsingSplit(String filename)
  4. loadClob(File f, String enc)
  5. loadCommonMisspellingsFile(String commonMisspellingsFileLocation)
  6. loadConfig(File conf)
  7. loadConfigProps(String configFile)
  8. loadContents(File file)
  9. loadCredentials(File credentials)