Java BufferedReader Read readFile(File f)

Here you can find the source of readFile(File f)

Description

read File

License

Apache License

Declaration

public static Map<String, String> readFile(File f) 

Method Source Code


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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, String> readFile(File f) {
        Map<String, String> map = new HashMap<>();
        try {/*from w  w  w .j  a v  a  2  s . c  om*/
            BufferedReader buffer = new BufferedReader(new FileReader(f));
            //List<String> lst =
            buffer.lines().filter(s -> s.matches("(?!#).*[ ]?=[ ]?.*")).forEach(s -> {
                String k[] = s.split("=");
                k[1] = k[1].split("#")[0].trim();
                map.put(k[0].trim(), k[1]);
            });
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return map;
    }
}

Related

  1. readFile(File f)
  2. readFile(File f)
  3. readFile(File f)
  4. readFile(File f)
  5. readFile(File f)
  6. readFile(File f)
  7. readFile(File f)
  8. readFile(File f)
  9. ReadFile(File f, boolean keep_newline)