• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File I/O - How to do?

 
Chris Mathews
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read from a file and then write to a file.
The input file looks like following :
07200608240190200105,WA07MA44,K
07200608340190200105,WA07MA37,K
07200608240190200105,WA07MA34_P2, K
07200608240190200105,WA07MA34_P1,K
07200608440190200105,WA07MA32,K
07200608340190200105,WA07MA31,K
07200608640190200105,WA07MA30_P2,K
07200608240190200105,WA07MA30_P2,K
07200608540190200105,WA07MA28_P2,K
07200608840190200105,WA07MA28_P1,K
07200608240190200105,WA07MA20_P2,K
07200608240190200105,WA07MA20_P2,K
07200608340190200105,WA07MA18,K
The Output should be :
The total Number of records in the input file : < the total number of records > -- In our case it should be 13
The number of unique values in the first column : This case it should be 6
The number of unique values in the secind column : This case it should be 11
I am cluseless about how to achieve this.Anybody please help me with the idea and/or code.
Thanks,
Chris.

 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Break it down into smaller tasks. First you need to read in from a file. Than work on what you get. Than write out to a file. Do you know how to read data in from a file? Once you read in from the file my guess is you would want to "tokenize" the strings so that you can work on them. Do you know how to do that?
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The solution is given and discussed at
http://www.javaranch.com/ubb/Forum1/HTML/001662.html
Please, stop CrossPosting. This is the third entry of the same topic (even if this is a better place as "intermediate" or programmer certification study"...).
Detlev
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic