package fileHandling;
import java.io.*;
public class Count_Words {
public static void main(String[] args) throws FileNotFoundException,IOException
{
StringBuffer sb = new StringBuffer();
BufferedReader br = new BufferedReader(new FileReader("D:\\work\\Java Work Space\\files\\demo.txt"));
String s = br.readLine();
while(s!= null)
{
sb = sb.append(s);
//System.out.println(s);
s = br.readLine();
sb.append(" ");
}
String s2 = sb.toString();
System.out.println(s2.length());
String[] words = s2.toLowerCase().split(" ");
}
}
import java.io.*;
public class Count_Words {
public static void main(String[] args) throws FileNotFoundException,IOException
{
StringBuffer sb = new StringBuffer();
BufferedReader br = new BufferedReader(new FileReader("D:\\work\\Java Work Space\\files\\demo.txt"));
String s = br.readLine();
while(s!= null)
{
sb = sb.append(s);
//System.out.println(s);
s = br.readLine();
sb.append(" ");
}
String s2 = sb.toString();
System.out.println(s2.length());
String[] words = s2.toLowerCase().split(" ");
}
}
No comments:
Post a Comment