Java BufferedReader Read loadTrustSet(String trustSet)

Here you can find the source of loadTrustSet(String trustSet)

Description

load Trust Set

License

Open Source License

Declaration

public static Map<String, Map<String, Double>> loadTrustSet(String trustSet) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.FileReader;

import java.util.HashMap;

import java.util.Map;

public class Main {
    public static Map<String, Map<String, Double>> loadTrustSet(String trustSet) throws Exception {
        BufferedReader fr = new BufferedReader(new FileReader(trustSet));

        Map<String, Map<String, Double>> userTNsMap = new HashMap<>();
        String line = null;//w ww.  j  a  v  a  2  s  . c om
        Map<String, Double> tns = null;
        while ((line = fr.readLine()) != null) {
            if (line.equals(""))
                continue;
            String[] data = line.split(" ");
            String trustor = data[0];
            String trustee = data[1];
            double trustScore = Double.parseDouble(data[2]);

            if (trustee.equals(trustor))
                continue; // to remove self-indicate entry

            if (userTNsMap.containsKey(trustor))
                tns = userTNsMap.get(trustor);
            else
                tns = new HashMap<>();

            tns.put(trustee, trustScore);
            userTNsMap.put(trustor, tns);
        }
        fr.close();

        return userTNsMap;
    }
}

Related

  1. loadTemplateParametersFile(File f)
  2. loadTestFixture(String path)
  3. loadTestUserEventRelation(String eventFilePath, HashMap> TestUser2EventIndexSetMap)
  4. loadToStringListFromFile(String fullFileName)
  5. loadTrustDistrustSets(String trust_data_set)
  6. loadTwoColumnResource(InputStream resource)
  7. loadTxnDescriptions(String filename)
  8. loadTXTList(String listFile, int size)
  9. loadUnicodeStringFromFile(final File file)