A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Certification
»
Certification Results
Author
HAHA
kerwin john abrinica
Greenhorn
Joined: Jan 15, 2012
Posts: 5
posted
Jan 23, 2012 23:58:35
0
import java.lang.*;
import java.io.*;
import
java.util.StringTokenizer
;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
public class WordCount
{
public static void main (
String
[] args)throws
IOException
{
FileReader
fr = new
FileReader
("wordCount_input.txt");
FileWriter
fw = new
FileWriter
("wordCount_output.txt");
BufferedReader
lolo = new
BufferedReader
(fr);
String s = lolo.readLine();
int tokenCount;
Double nono;
StringTokenizer
st = new
StringTokenizer
(s);
tokenCount = st.countTokens();
System.out.println("Number of tokens = " + tokenCount );
}
public static void s(String roro){
while (st.hasMoreTokens()){
System.out.println();
while(st.hasMoreElements()){
StringTokenizer
zt = new
StringTokenizer
(s);
int tokenCount1 = zt.countTokens()/zt.countTokens();
double tokenCount2 = zt.countTokens()/zt.countTokens();
NumberFormat
formatter = new
DecimalFormat
("#0.00");
nono = tokenCount2 / tokenCount;
System.out.println( "\t\t" + tokenCount1 + "\t" + formatter.format(nono));
fw.write("\r\t\t" + tokenCount1 + "\t" + formatter.format(nono));
break;
}
// fr.close();
// fw.close();
}
}
}
John Jai
Bartender
Joined: May 31, 2011
Posts: 1776
posted
Jan 24, 2012 00:14:04
0
Please
UseAMeaningfulSubjectLine
and
UseCodeTags
. Why have you posted in Certification Results forum with subject line "HAHA"
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: HAHA
Similar Threads
text file
Writing to File
Java Writer, Java Filer, Tokenizer
FileIO
reverse the text file and write
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter