Java Properties Load from File loadHeader(String fileName)

Here you can find the source of loadHeader(String fileName)

Description

Read the header part of a properties file into a String.

License

Apache License

Parameter

Parameter Description
fileName a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static String loadHeader(String fileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;

import java.io.FileReader;
import java.io.IOException;

public class Main {
    /**/*from   w  ww. j  ava 2s . com*/
     * Read the header part of a properties file into a String. 
     * @param fileName
     * @return
     * @throws IOException
     * 
     */
    public static String loadHeader(String fileName) throws IOException {
        FileReader fr = null;
        BufferedReader br = null;
        try {
            fr = new FileReader(fileName);
            br = new BufferedReader(fr);
            String header = br.readLine();
            if (header != null && header.indexOf('#') == 0) {
                header = header.substring(1);
            }
            return header;
        } finally {
            if (br != null) {
                br.close();
            }
            if (fr != null) {
                fr.close();
            }
        }
    }
}

Related

  1. loadErrorMap(InputStream resourceStream)
  2. loadEscaping(Properties prop, InputStream stream)
  3. loadFixedCommits()
  4. loadFixture(String fixtureId)
  5. loadGradleResource(String fileName)
  6. loadIncludes(String propertyName, boolean mandatory, File file, Properties configProps)
  7. loadInputAsString(InputStream is)
  8. loadInstallProps()
  9. loadJZ(File file)