puntito
Programmer
- Mar 22, 2006
- 18
Hi:
I need to do a program wich reads a text file.
a) count the number of words that the text have (a word is any secuence of characters, not containing space blankets, tabs or end lines).
b) Count the number of lines.
c) Replace a String with another one, sended like a parameter.
c) Send the result to the standard output.
Ohh God¡¡¡
I don't have an idea of how to read the file.
a) b)
String text="I love my dog";
String chk= new String();
int countr=0;
int cntln=0;
int x=text.length();
for (int i=0;i<x;i++)
{
if (text==" " && text=="/n" && text="/t")
countr++;
if (text=="/nl" )
{ cntln++;
countr++;}
}
c) d)
String str1="I hate my old car";
Strin str2= new String();
str2= str1.replaceAll("hate", "love");
System.out.println(str2);
Is this correct??
Is there a different way to do it???
Do I need to correct something??
Help me please¡¡¡¡
I need to do a program wich reads a text file.
a) count the number of words that the text have (a word is any secuence of characters, not containing space blankets, tabs or end lines).
b) Count the number of lines.
c) Replace a String with another one, sended like a parameter.
c) Send the result to the standard output.
Ohh God¡¡¡
I don't have an idea of how to read the file.
a) b)
String text="I love my dog";
String chk= new String();
int countr=0;
int cntln=0;
int x=text.length();
for (int i=0;i<x;i++)
{
if (text==" " && text=="/n" && text="/t")
countr++;
if (text=="/nl" )
{ cntln++;
countr++;}
}
c) d)
String str1="I hate my old car";
Strin str2= new String();
str2= str1.replaceAll("hate", "love");
System.out.println(str2);
Is this correct??
Is there a different way to do it???
Do I need to correct something??
Help me please¡¡¡¡