Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import lineals.*;
- /**
- * Write a description of class concor here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class concor
- {
- public static void main(String args[]) throws IOException {
- if(args.length > 2){
- System.out.println("Ús: concor [Opcions] [nomFiterEnt]");
- System.exit(-1);
- }
- System.out.println("NUM args: " + args.length);
- boolean ord = false;
- Scanner ent = new Scanner(System.in);
- if(args.length >= 1){
- if(args[0].equals("-o")) ord = true;
- if(!(args[args.length-1].equals("-o")))
- ent = new Scanner(new File(args[args.length-1]));
- }
- Concordanca cnc = new Concordanca();
- String separadors = "[\\p{Space}\\p{Punct}\\p{Digit}¡¿]";
- int contaLin = 0;
- while(ent.hasNextLine()){
- contaLin++;
- String line = ent.nextLine().trim();
- String aux[] = line.split(separadors);
- for(int i=0; i<aux.length;i++){
- String pal=processar(aux[i]);
- if(pal.length()!=0){
- if(ord) cnc.insOrd(pal,contaLin);
- else cnc.inserir(pal,contaLin);
- }
- }
- }//de while
- System.out.println(cnc);
- }// de main
- public static String processar(String s){
- return s.trim();
- }
- }// de class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement