Java BufferedReader Read loadNameMap(String mapName, boolean reverseMap)

Here you can find the source of loadNameMap(String mapName, boolean reverseMap)

Description

load Name Map

License

LGPL

Declaration

private static Map<String, List<String>> loadNameMap(String mapName, boolean reverseMap) throws IOException 

Method Source Code


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

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.HashMap;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class Main {
    private static Map<String, List<String>> loadNameMap(String mapName, boolean reverseMap) throws IOException {
        Map<String, List<String>> rtrn = new HashMap<String, List<String>>();
        String line;/*from w  w  w .  ja va  2  s  .c om*/
        BufferedReader br = new BufferedReader(new FileReader(mapName));

        while ((line = br.readLine()) != null) {
            String[] lineSplit = line.split("\t");

            String n1 = lineSplit[0];
            String n2 = lineSplit[1];
            if (reverseMap) {
                n1 = lineSplit[1];
                n2 = lineSplit[0];
            }
            if (!rtrn.containsKey(n1)) {
                List<String> lst = new LinkedList<String>();
                rtrn.put(n1, lst);
            }
            rtrn.get(n1).add(n2);
        }
        br.close();
        return rtrn;
    }
}

Related

  1. loadLongArray(BufferedReader in)
  2. loadMetadata(File file)
  3. loadMetaFile(File metaFile)
  4. loadMimeTypes(Reader in, Map extMap, Map mimeMap)
  5. loadModel(String fileName, Hashtable dictionary, Hashtable> modelPairs)
  6. loadNumUsers(String fileName)
  7. loadPartitions(String fileName)
  8. loadPathPreferencesFromFile(File inputFile)
  9. loadPrivateKeyFile(File privateKeyFile)