Results 1 to 1 of 1
- 03-10-2011, 02:32 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
output shows undesired results(advice ?)
the output :Java Code:System.out.println("Please enter the required word :"); Scanner scan2 = new Scanner(System.in); String word2 = scan.nextLine(); String[] array2 = word2.split(" "); for (int i = 0; i < filename; i++) { int numofDoc = 0; for (int b = 0; b < array.length; b++) { try { BufferedReader in = new BufferedReader(new FileReader( "C:\\Users\\user\\fypworkspace\\TextRenderer\\abc" + i + ".txt")); int matchedWord = 0; Scanner s2 = new Scanner(in); { while (s2.hasNext()) { if (s2.next().equals(word2)) matchedWord++; } } if (matchedWord > 0) numofDoc++; System.out.println("File containing the term is " + numofDoc); } catch (IOException e) { System.out.println("File not found."); }
This file contain the term 0
This file contain the term 0
This file contain the term 1
This file contain the term 0
This file contain the term 0
This file contain the term 0
File not found.
This file contain the term 0
This file contain the term 0
This file contain the term 1
This file contain the term 1
I got this output but the output i wanted is the result prints only one line summing up all the counter.
Example : The file containing the term is 3. Only one line of print.
Any advices ?
Similar Threads
-
Environment variable shows different from editable value
By projecttoday in forum New To JavaReplies: 6Last Post: 12-01-2010, 12:47 AM -
Output console results to a HTML browser
By JTS25 in forum New To JavaReplies: 5Last Post: 11-04-2010, 06:25 PM -
To_date function through Java shows timestamp
By mpavithra in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 07-29-2010, 08:59 AM -
Output to results file help!
By javanator in forum New To JavaReplies: 6Last Post: 04-18-2010, 01:59 AM -
JTable in Frame only shows 3 rows
By Laura Warren in forum New To JavaReplies: 4Last Post: 12-24-2008, 05:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks