This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Storing a few records in a hashmap one by one .

kirankkmm kumar

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 .


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
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

Joined: Mar 22, 2005
Posts: 41124
"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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Storing a few records in a hashmap one by one .
Similar Threads
weblogic8.1 with open LDAP authentication
Reading a line from text file
ApacheDS 1.0.2 LDAP Connection timed out: connect
Reading a text file by storing in hashmap
Reading a text file and then generate other output