Created
December 4, 2012 00:36
-
-
Save krishnanraman/4199415 to your computer and use it in GitHub Desktop.
IPGetter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ip(host:String)=java.net.InetAddress.getAllByName(host)(0).getHostAddress | |
var map = Map[String,String]() | |
val hosts = List("google.com","twitter.com","facebook.com") | |
hosts.par.map(host => (host,ip(host))).foreach(hostip => map+=(hostip._1->hostip._2)) | |
scala> map | |
res1: scala.collection.immutable.Map[String,String] = Map(google.com -> 74.125.224.71, twitter.com -> 199.59.150.7, facebook.com -> 69.171.229.16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment