Here you can find the source of loadTrace(File file)
Parameter | Description |
---|---|
file | to read from |
public static Map<String, Map<Integer, Integer>> loadTrace(File file)
//package com.java2s; /*/* ww w . ja va 2s .c om*/ * Copyright (C) 2011 Saarland University * * This file is part of Javalanche. * * Javalanche is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Javalanche is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with Javalanche. If not, see <http://www.gnu.org/licenses/>. */ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.Map; import java.util.zip.GZIPInputStream; public class Main { /** * Loads a trace from the given file. Returns a map with key method names as * keys and an int to int map as value. The key has the from * className@methodName. * * @param file * to read from * * @return a map with key method names as keys and an int to int map as * value. */ public static Map<String, Map<Integer, Integer>> loadTrace(File file) { Map<String, Map<Integer, Integer>> classMap = new HashMap<String, Map<Integer, Integer>>(); ObjectInputStream ois; try { ois = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)))); int numClasses = ois.readInt(); for (int i = 0; i < numClasses; i++) { String className = ois.readUTF(); int numLines = ois.readInt(); Map<Integer, Integer> lineMap = new HashMap<Integer, Integer>(); for (int j = 0; j < numLines; j++) { lineMap.put(ois.readInt(), ois.readInt()); } classMap.put(className, lineMap); } ois.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return classMap; } }