Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.eda.practica03.ejercicio01;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.StringTokenizer;
- import java.util.TreeMap;
- import org.eda.estructurasdatos.Iterator;
- public class ProcesarDirecciones {
- private TreeMap<String,TreeMap<String,Integer>> ips = new TreeMap<String,TreeMap<String,Integer>> ();
- public ProcesarDirecciones() {
- super();
- this.ips = ips;
- }
- public void cargarArchivo(String archivoEntrada) {
- try {
- File txt = new File(archivoEntrada);
- FileReader fr = new FileReader(txt);
- BufferedReader in = new BufferedReader(fr);
- String aux, aux2[], direccion, maq;
- while ((aux = in.readLine()) != null) {
- aux2=troceador(aux);
- direccion = aux2[0];
- maq = aux2[1];
- TreeMap<String,Integer> maqContador = new TreeMap<String,Integer>();
- maqContador.put(maq, 1);
- if(ips.containsKey(direccion)){
- if(ips.get(direccion).containsKey(maq)){
- Integer contador=ips.get(direccion).get(maq);
- contador++;
- ips.get(direccion).put(maq, contador);
- }
- else{
- ips.get(direccion).put(maq, new Integer(1));
- }
- }
- else{
- ips.put(direccion, maqContador);
- }
- }} catch (FileNotFoundException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public int tamano() {
- return ips.size();
- }
- public void generarDirecciones(String archivoSalida) {
- FileWriter txt = new FileWriter(archivoSalida);
- PrintWriter writer = new PrintWriter(txt);
- Iterator<String,TreeMap<String,Integer>> it = ips.keySet().iterator();
- for()
- }
- public void generarIncidencias(String archivoSalida) {
- // TODO Auto-generated method stub
- }
- private static String[] troceador(String linea) {
- StringTokenizer b = new StringTokenizer(linea);
- int j = 0;
- String z[] = new String[2];
- while (b.hasMoreTokens()) {
- z[j] = b.nextToken(" ");
- j++;
- }
- return z;
- }
- }
Add Comment
Please, Sign In to add comment