File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Storing a few records in a hashmap one by one . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Storing a few records in a hashmap one by one .

kirankkmm kumar
Greenhorn

Joined: Sep 17, 2010
Posts: 7

I need to store a a number of records in hashmap by reading it from text file.

below is the code .






//testall.ldif


dn: uid=br152, ou=People, dc=acceg,dc=ag,dc=com
displayName: br152
homePhone: 87878
givenName: Nickkk
aigrole: SWC_Brokery
mobile: 888667575

dn: uid=br152g, ou=People, dc=acce,dc=ng,dc=com
displayName: br152g
homePhone: 56565
givenName: Nickfsfsf
aigrole: SWoker
mobile: 343434675


dn: uid=br1, ou=People, dc=achg,dc=aig,dc=com
displayName: br1
homePhone:
givenName: dfdf
aigrole: dfser
mobile: 6575755756



The output should be as below





Please do the needful ,help me to resolve this issue.


thanks in advance

Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
What's the issue? The code is not complete at all. Take the map declaration out of the loop. It will keep on creating new map at every iteration.
Go through collection api thoroughly and try yourself. You need to use the map's put() method a for-each loop and a bit of logic to complete the code. Best of luck


Java Programmer | SCJP 1.5 | SCWCD 1.4
Soumyajit Hazra
Ranch Hand

Joined: Jun 26, 2007
Posts: 136
Take a look at Head First Java.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41855
    
  63
"kirankkmm kumar",
it is quite annoying that you continue to post the same question over and over again, despite having been asked repeatedly not to do that. There comes a time when it's just easier for the moderators of this site to close your account than to try to work with you. If you require further assistance with this question, ask follow-ups in the other thread where you posted this code; do not start yet another one.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing a few records in a hashmap one by one .