6

I want to set the ipaddress in variable using scala. I have tried below scenario. I did not get exactly what I was looking for.

val sysip = System.InetAddress.getLocalHost();

Can you please help?

Tzach Zohar
  • 37,442
  • 3
  • 79
  • 85
Nathon
  • 165
  • 1
  • 4
  • 13

1 Answers1

10
import java.net._

val localhost: InetAddress = InetAddress.getLocalHost
val localIpAddress: String = localhost.getHostAddress

println(s"localIpAddress = $localIpAddress")

You can find more details via this link

fcat
  • 1,251
  • 8
  • 18