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. 在global.asax中启动定时任务

    public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { Area ...

  2. 分布式理论——从ACID到CAP再到BASE

    在传统的数据中,有ACID四大原则,在分布式中也有对应的CAP理论和BASE理论,这些都是分布式理论的基础. 更多内容参考:大数据学习之路 ACID ACID分别是Atomicity 原子性.Cons ...

  3. Reactor 3 学习笔记(1)

    Reactor 3 与之前学习的RxJava是同一类(反应式编程)框架,基本概念大致差不多,简单记录一下: Reactor 3 利用了java 8中的CompletableFuture.Stream. ...

  4. EF6 简单增删改查示例代码

    示例一: private DbContext _dbContext; public DbContext CurrentContext { get { if (_dbContext == null) { ...

  5. 转载: ASP.NET Core入门系列文章

    今天在网上发现了ithome上的asp.net core 系列文章,对于新手入门还不错,这里转载一下,也方便查阅. [Day01] 從頭開始 [Day02] 程式生命週期 (Application L ...

  6. import pandas as pd Python安装pandas模块

    在学习python过程中需要用到一个叫pandas的模块,在pycharm中安装时总是出错. 千般百度折腾还是无果,后来发现它需要安装很多依赖包.就问你气不气~ 需要手动安装啊,千万记住,这里有个py ...

  7. linux下安装python dlib依赖

    dlib是主要用于机器学习的库,封装了机器学习算法,可以非常方便的实现比如人脸识别,车辆识别,物体检测以其他很多功能,dlib默认使用C++进行开发,另外图像识别有一部分支持python接口开发,上手 ...

  8. Android中将十六进制 颜色代码 转换为int类型数值

    Android中 将 十六进制 颜色代码 转换为  int   类型数值 方法  : Color.parseColor("#00CCFF") 返回 int 数值 来自为知笔记(Wi ...

  9. python eric6 IDE

    之前开发一直使用sublime text + anaconda, 无意中发现了eric, Python主流IDE对比:Eric VS. PyCharm 使用IDE绝对是能提高开发效率的... http ...

  10. 微信公众号基础02_获取accessToken和用户信息

    上一篇分享了搭建微信公众号server,本文分享一下假设获取access_Token和用户信息.工具还是新浪云SAE 1.获取access_Token 相见开发文档:https://mp.weixin ...