scala 用 isInstanceOf 会报错(instanceof 这个函数就没有),java 下使用  instanceof 来判断是否是 Inet4Address

test("get ipv4 address") {

  val ipAddr = InetAddress.getLocalHost.getHostAddress

  val interfaces: util.Enumeration[NetworkInterface] = NetworkInterface.getNetworkInterfaces

  while(interfaces.hasMoreElements) {
val ele = interfaces.nextElement val addrs: util.Enumeration[InetAddress] = ele.getInetAddresses while(addrs.hasMoreElements) {
val addr: InetAddress = addrs.nextElement() addr match {
case some: Inet4Address if !addr.isLoopbackAddress =>
println(some.getHostAddress)
case _ =>
// do nothing
} }
} }

scala get ipv4 address的更多相关文章

  1. Windows7 Autoconfiguration IPv4 Address 导致无法上网

    Windows7 Autoconfiguration IPv4 Address 导致无法上 (2010-03-30 16:44:57) 转载▼ 标签: 杂谈 分类: 电脑软件问题 Windows7 A ...

  2. 【解决】could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

    在同一套环境中跑了很多个项目都是用 docker-compose的方式启动的,导致创建的自定义网络过多出现下面的报错 Error response from daemon: could not fin ...

  3. How to convert an IPv4 address into a integer in C#?

    仅仅针对于IPv4的处理方法 从string转换为int 以及从int转换为string // IPv4 int intAddress = BitConverter.ToInt32(IPAddress ...

  4. docker could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

    原因: 无法进行网络分配了 解决方法: // 所有的网络 docker network ls // 删除不用的,腾出多余的 docker network rm <networkname> ...

  5. [LeetCode] Validate IP Address 验证IP地址

    In this problem, your job to write a function to check whether a input string is a valid IPv4 addres ...

  6. Leetcode: Validate IP Address

    In this problem, your job to write a function to check whether a input string is a valid IPv4 addres ...

  7. IP address/地址 检查

    1.Determine if a string is a valid IP address in C Beej's Guide to Network Programming 2.9.14. inet_ ...

  8. ------- 当前全球最新的 IPv4 地址池使用报告 -------

    -------------------------------------------------------------- 对于互联网行业相关的从业人员而言,时刻关注 IPv4 地址池的状态此类&q ...

  9. [Swift]LeetCode468. 验证IP地址 | Validate IP Address

    Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither ...

随机推荐

  1. emSecure Use Digital Signatures to protect your products

    emSecure Use Digital Signatures to protect your products emSecure is an RSA based software solution ...

  2. 设置Tab键缩进2字符

    默认是1.74cm,是1.5字符. 论文是4个空格显示为4个点,或者全角下2个空格,显示为2个空格框.看上方的首航缩进标志是否在2. 看图 在段落 格式里面进行设置! 点上图的制表位 打开下图 选默认 ...

  3. JavaScript数组所有API全解密

    全文共13k+字,系统讲解了JavaScript数组的各种特性和API. 数组是一种非常重要的数据类型,它语法简单.灵活.高效. 在多数编程语言中,数组都充当着至关重要的角色,以至于很难想象没有数组的 ...

  4. 开源框架完美组合之Spring.NET + NHibernate + ASP.NET MVC + jQuery + easyUI 中英文双语言小型企业网站Demo(转)

    热衷于开源框架探索的我发现ASP.NET MVC与jQuery easyUI的组合很给力.由于原先一直受Ext JS框架的licence所苦恼,于是痛下决心寻找一个完全免费的js框架——easyUI. ...

  5. 使用GPStracker自建卫星定位跟踪平台

    经常有人问,我能不能手机定位跟踪谁谁谁,我能不能定位跟踪我的车,等等问题. 话说不难,确实,需要客户端和服务端结合起来就能实现. 今天就给大家介绍一下GPStracker,一套开源的定位跟踪系统,有手 ...

  6. 【ZH奶酪】为什么Python不需要函数重载?

    函数重载的作用是什么? 函数重载主要是为了解决两个问题 可变参数类型 可变参数个数 另外,一个基本的设计原则是,仅仅当两个函数除了参数类型和参数个数不同以外,其功能是完全相同的,此时才使用函数重载,如 ...

  7. Java 基础【17】 异常与自定义异常

    1.异常的分类 Throwable 是所有异常类的基类,它包括两个子类:Exception 和 Error. a. 错误 (Error) 错误是无法难通过程序来解决的,所以程序不应该抛出这种类型的对象 ...

  8. 查看tar文件的顶层目录

    方法一: tar -tf udpSocket.tar | awk -F "/" '{print $1}' | sort | uniq 方法二: tar -tf udpSocket. ...

  9. 【LeetCode】242. Valid Anagram (2 solutions)

    Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. For ...

  10. 3.翻译系列:EF Code-First 示例(EF 6 Code-First系列)

    原文链接:http://www.entityframeworktutorial.net/code-first/simple-code-first-example.aspx EF 6 Code-Firs ...