Results 1 to 14 of 14
Thread: a doubt
- 11-22-2009, 04:10 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
-
You may wish to clarify your question so that it can be more easily answered. Best of luck.
- 11-22-2009, 05:07 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you bit more specific? What objects are you looking in a text file, the word object confusing. And also what you've tried so far?
-
Hello Eranga! :)
- 11-22-2009, 05:10 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Hi Fubarable. :)
I've just post earlier replay at the same time I guess... :P
- 11-22-2009, 05:16 PM #6
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
contents in my text file are like this:
climate temperature humidity
/*The above three are the column names*/
hot high mild
hot mild cold
cool mild low..
the list goes on like this.. I wish to find number of occurences of hot,cool in the the column climate..similarly i wish to find the number of occurences of high,mild in the column temerature..
- 11-22-2009, 05:19 PM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
First read line by line of the text file. Can you do that?
- 11-22-2009, 05:20 PM #8
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
ya.. i can do that.. but how to find occurences in each column?
- 11-22-2009, 05:32 PM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you can read the line of text, then tokernize by using the space character and keep them in an array. Them you can compare with what you want to do the process.
But this method not more efficient, because you have to deal with the counters are well. Collections in java like List, Map do the job in much better way in such instance.
- 11-22-2009, 05:34 PM #10
Member
- Join Date
- Nov 2009
- Posts
- 4
- Rep Power
- 0
can you send me a sample code for that?
-
Why not try to solve it first on your own, then if you run into a problem, post your attempted solution and we can help you work on it.
- 11-23-2009, 02:45 AM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 11-23-2009, 06:35 AM #13
Senior Member
- Join Date
- Jan 2009
- Posts
- 119
- Rep Power
- 0
you could also try counting as u read, like anytime you read you check then increment the appropriate counter. it would make your program a bit faster.
- 11-24-2009, 02:26 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You've lots of ways to gain performance in the code, but the most important thing is that the basic model of the application.
If you've tried something and looking any feedback, post your code here.
Similar Threads
-
Doubt
By karthikeyan_raju in forum Advanced JavaReplies: 11Last Post: 11-05-2009, 04:48 PM -
have doubt
By ras_pari in forum Advanced JavaReplies: 3Last Post: 10-01-2009, 09:51 AM -
doubt
By Chris555 in forum NetworkingReplies: 0Last Post: 08-05-2009, 02:58 PM -
Doubt
By winkodes in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 12-20-2008, 08:34 PM -
doubt
By shaju_inspira in forum Sun Java Wireless ToolkitReplies: 0Last Post: 01-18-2008, 08:38 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks