Here you can find the source of loadPartitions(String fileName)
Parameter | Description |
---|---|
fileName | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static Map<Integer, Integer> loadPartitions(String fileName) throws IOException
//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; } }