Java FileInputStream Read readFile(String fileName)

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

Description

read File

License

Open Source License

Declaration

static Properties readFile(String fileName) throws Exception 

Method Source Code

//package com.java2s;
// Distributed under an Apache License

import java.io.File;
import java.io.FileInputStream;

import java.util.Properties;

public class Main {
    static Properties readFile(String fileName) throws Exception {
        File f = new File(fileName);
        if (!f.exists()) {
            throw new IllegalArgumentException("No such file: " + f.getCanonicalPath());
        }/*from w  ww  .j  a  v a 2  s  . c  om*/
        FileInputStream in = null;
        try {
            Properties prop = new Properties();
            in = new FileInputStream(f);
            prop.load(in);
            return prop;
        } finally {
            if (in != null)
                try {
                    in.close();
                } catch (Exception ignore) {
                }
        }

    }
}

Related

  1. readFile(String file)
  2. readFile(String file)
  3. readFile(String file)
  4. readFile(String file)
  5. readFile(String filename)
  6. readFile(String fileName)
  7. readFile(String filename)
  8. readFile(String fileName)
  9. readFile(String filename)