/** preprocessDataset Task 1 */ private void preprocessDataset() { BufferedReader br = null; FileOutputStream fos = null; PrintStream ps = null; try { fos = new FileOutputStream(Constants.preprocessFile); ps = new PrintStream(fos); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String line = ""; try { br = new BufferedReader(new FileReader(Constants.bgpdata)); while ((line = br.readLine()) != null) { // && index < 5 if (line.contains("{") || line.contains("}")) { // System.out.println(line); } else { String ASString = line.substring(Constants.bpgdataPrefix.length()); String[] ASes = ASString.split(" "); if (ASes.length == 0 || ASString.equals("")) { continue; } List<Integer> asKeysInpath = new ArrayList<Integer>(); for (int i = 0; i < ASes.length; i++) { Integer asKey = Integer.parseInt(ASes[i]); if (asKeysInpath.indexOf(asKey) < 0) { asKeysInpath.add(asKey); } if (!asMap.containsKey(asKey)) { AS newAs = new AS(asKey.intValue()); asMap.put(asKey, newAs); originAsMap.put(asKey, newAs); } } AS[] asesInpath = new AS[asKeysInpath.size()]; for (int i = 0; i < asKeysInpath.size(); i++) { asesInpath[i] = asMap.get(asKeysInpath.get(i)); } ASPath path = new ASPath(asesInpath); // System.out.println("path:"+path.toString()); if (!asPathMap.containsKey(path.toString())) { asPathMap.put(path.toString(), path); ps.println(path.toString()); } } // String[] orderline = line.split(","); } System.out.println("Number of ASes: " + asMap.size()); ps.println("Number of ASes: " + asMap.size()); System.out.println("Number of AS paths:" + asPathMap.size()); ps.println("Number of AS paths:" + asPathMap.size()); // System.out.println("duplicated aspathes:"+index); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }