Вы находитесь на странице: 1из 2

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package reader;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
/**
*
* @author Eduardo Daniel Marquez Vega
*/
public class Main {
public Main(String fn, String palabra){
long st= System.currentTimeMillis(); //tiempos de reloj de java (S.O.)
fileName = fn;
this.palabra=palabra;
feedLine (getPipe(fileName));
long et= System.currentTimeMillis(); //tiempos de reloj de java (S.O.)
loadTime = (et - st); //restando los tiempos sacamos el tiempo que lleva el p
rograma en ejecucion
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String fileName = args[0].toString();
String palabra = args[1].toString();
System.out.println("Archivo de trabajo:"+fileName);
new Main(fileName,palabra);
}
private BufferedReader getPipe(String fn){
BufferedReader bur=null;
try{
FileReader fr = new FileReader(fn);
bur = new BufferedReader(fr);
}
catch(Exception e){
System.err.println("Err:"+ e.getLocalizedMessage());
System.exit(-1);
}
return bur;
}
private void feedLine (BufferedReader bur){
Scanner scr= null;
try{

while (bur.ready()){
String line=bur.readLine();
scr = new Scanner(line).useDelimiter(" ");
while (scr.hasNext()){
String LineasSegmentadas = scr.next();
System.out.println(LineasSegmentadas);
}
}
}
catch(Exception e){
System.err.println("ERR: "+ e.getLocalizedMessage() );
}
}
String fileName="";
long loadTime;
String palabra;
private Runtime r;
}

Вам также может понравиться