Advertisement
nRikee

concor

Jun 1st, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. import lineals.*;
  4.  
  5. /**
  6.  * Write a description of class concor here.
  7.  *
  8.  * @author (your name)
  9.  * @version (a version number or a date)
  10.  */
  11. public class concor
  12. {
  13.     public static void main(String args[]) throws IOException {
  14.         if(args.length > 2){
  15.             System.out.println("Ús: concor [Opcions] [nomFiterEnt]");
  16.             System.exit(-1);
  17.         }
  18.        
  19.         System.out.println("NUM args: " + args.length);
  20.        
  21.         boolean ord = false;
  22.         Scanner ent = new Scanner(System.in);
  23.         if(args.length >= 1){
  24.             if(args[0].equals("-o")) ord = true;
  25.             if(!(args[args.length-1].equals("-o")))
  26.                 ent = new Scanner(new File(args[args.length-1]));
  27.         }
  28.        
  29.         Concordanca cnc = new Concordanca();
  30.        
  31.         String separadors = "[\\p{Space}\\p{Punct}\\p{Digit}¡¿]";
  32.        
  33.         int contaLin = 0;
  34.        
  35.         while(ent.hasNextLine()){
  36.             contaLin++;
  37.             String line = ent.nextLine().trim();
  38.             String aux[] = line.split(separadors);
  39.             for(int i=0; i<aux.length;i++){
  40.                 String pal=processar(aux[i]);
  41.                 if(pal.length()!=0){
  42.                     if(ord) cnc.insOrd(pal,contaLin);
  43.                     else cnc.inserir(pal,contaLin);
  44.                 }
  45.             }
  46.         }//de while
  47.         System.out.println(cnc);
  48.     }// de main
  49.    
  50.     public static String processar(String s){
  51.         return s.trim();
  52.     }
  53. }// de class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement