Java BufferedReader Read loadPartitions(String fileName)

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

Description

load Partitions

License

LGPL

Parameter

Parameter Description
fileName a parameter

Exception

Parameter Description
IOException an exception

Return

partitions loaded from the given file.

Declaration

public static Map<Integer, Integer> loadPartitions(String fileName) 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.Map;

public class Main {
    /**//from w ww .j  ava2 s  .  c o m
     * 
     * @param fileName
     * @return partitions loaded from the given file.
     * @throws IOException
     */
    public static Map<Integer, Integer> loadPartitions(String fileName) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(fileName));
        Map<Integer, Integer> result = new HashMap<Integer, Integer>();

        String line;
        while ((line = reader.readLine()) != null) {
            String[] tokens = line.split(" ");
            assert (tokens.length == 2);
            int lit = Integer.parseInt(tokens[0]);
            int partition = Integer.parseInt(tokens[1]);
            result.put(lit, partition);
        }

        reader.close();
        return result;
    }
}

Related

  1. loadMetaFile(File metaFile)
  2. loadMimeTypes(Reader in, Map extMap, Map mimeMap)
  3. loadModel(String fileName, Hashtable dictionary, Hashtable> modelPairs)
  4. loadNameMap(String mapName, boolean reverseMap)
  5. loadNumUsers(String fileName)
  6. loadPathPreferencesFromFile(File inputFile)
  7. loadPrivateKeyFile(File privateKeyFile)
  8. loadQueryFromFile(String queryFile)
  9. loadQueryNodeInfo(String input_file)