Site hosted by Angelfire.com: Build your free website today!

import java.lang.*;

import java.io.*;

import Misclases.*;

import java.util.*;

class Pro55

{

public static void main(String [] args)

{

String nombre,re,s=" ";

char car,c;

String texto=new String();

int i=0,con=0,a=0;

FileReader leer= null;

BufferedReader lectura=null;

while(true){

System.out.print("\nNombre de archivo: ");

nombre=Getdat.getCad();

try

{

leer= new FileReader(nombre);

lectura=new BufferedReader(leer);

while(s!=null)

{

s = lectura.readLine();

texto +=s;

texto +="\n";

}

}

catch(EOFException e)

{

System.out.println("Fin de archivo");

}

catch (NullPointerException e)

{

System.out.println("Error");

}

catch (IOException e)

{

System.out.println("Error");

}

finally

{

try

{

if(lectura!=null)

{

lectura.close();

leer.close();

}

}

catch(IOException e)

{

System.out.println("Error");

}

}

System.out.print("\n"+texto);

System.out.print("\n");

con=0;

for(car=32;car<126;car++)

{

for(i=0;i<texto.length();i++)

{

c=texto.charAt(i);

if(car==c)

con++;

}

if(con>0)

System.out.print("Car: "+car+" = "+con+"\t");

con=0;

}

for(i=0;i<texto.length();i++)

{

c=texto.charAt(i);

if('\n'==c)

con++;

}

con=con-1;

System.out.print("\n\nLineas = "+con+" ");

con=0;

for(i=0;i<texto.length();i++)

{

c=texto.charAt(i);

// if(texto.charAt(i+1)!='\n'){

// if((' '==c || '\n'==c)&&(texto.charAt(i+1)!=' '||texto.charAt(i+1)!='\n'))

// con++;}

// if(texto.charAt(i+1)=='\n'){

if(' '==c || '\n'==c)//&&(texto.charAt(i+1)!=' '||texto.charAt(i+1)!='\n'))

con++;//}

}

con=con-1;

System.out.print("\n\nPalabras = "+con+" ");

con=0;

s=" ";

texto="";

try

{

leer.close();

lectura.close();

}

catch(IOException e)

{

System.out.println("Error2");

}

System.out.print("\nDeseas continuar s/n: ");

re=Getdat.getCad();

if(re.equals("n")==true)

break;

else{}}

}

}