scala get ipv4 address
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的更多相关文章
- Windows7 Autoconfiguration IPv4 Address 导致无法上网
Windows7 Autoconfiguration IPv4 Address 导致无法上 (2010-03-30 16:44:57) 转载▼ 标签: 杂谈 分类: 电脑软件问题 Windows7 A ...
- 【解决】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 ...
- How to convert an IPv4 address into a integer in C#?
仅仅针对于IPv4的处理方法 从string转换为int 以及从int转换为string // IPv4 int intAddress = BitConverter.ToInt32(IPAddress ...
- 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> ...
- [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 ...
- Leetcode: Validate IP Address
In this problem, your job to write a function to check whether a input string is a valid IPv4 addres ...
- IP address/地址 检查
1.Determine if a string is a valid IP address in C Beej's Guide to Network Programming 2.9.14. inet_ ...
- ------- 当前全球最新的 IPv4 地址池使用报告 -------
-------------------------------------------------------------- 对于互联网行业相关的从业人员而言,时刻关注 IPv4 地址池的状态此类&q ...
- [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 ...
随机推荐
- og4j日志文件乱码问题的解决方法
现象:在默认语言非中文(或者说默认语言不支持中文的)的Windows.Linux.Unix上,用log4j打印日志,出现乱码,常见的就是一堆问号. 解决方法: 如果是log4j.properties为 ...
- 阿里云 RDS 与 DRDS 学习了解
RDS 主页:https://help.aliyun.com/document_detail/26092.html?spm=5176.7741872.6.539.4h8LSC DRDS 主页:http ...
- 一步一步开发sniffer(Winpcap+MFC)(五)莫道无人能识君,其实我懂你的心——解析数据包(转)
前文已经讲过,解析数据包主要通过analyze_frame()这个函数实现的,实际上并非这个函数完成了所有的功能,其实从名字就可以看出,它只是完成了对“帧”的解析,也就是链路层数据的解析,还有anal ...
- Spark机器学习(7):KMenas算法
KMenas算法比较简单,不详细介绍了,直接上代码. import org.apache.log4j.{Level, Logger} import org.apache.spark.{SparkCon ...
- openjudge noi 买房子
题目链接:http://noi.openjudge.cn/ch0105/16/ 总时间限制: 1000ms 内存限制: 65536kB 描述 某程序员开始工作,年薪N万,他希望在中关村公馆买一套60平 ...
- 【Android】解析Paint类中MaskFilter的使用
目录结构: contents structure [+] EmbossMaskFilter BlurMaskFilter MaskFilter可以用来指定画笔的边缘效果.如果引用开启硬件加速的话,那么 ...
- Self-Host
寄宿Web API 不一定需要IIS 的支持,我们可以采用Self Host 的方式使用任意类型的应用程序(控制台.Windows Forms 应用.WPF 应用甚至是Windows Service) ...
- 设置log rotation避免tomcat catalina.out文件增长过大
创建logrotate配置文件 $ vi /etc/logrotate.d/tomcat 添加以下内容: /opt/tomcat/logs/catalina.out { copytruncate da ...
- 把linux的man手册转化为windows下可读的格式
原文链接: http://www.linux521.com/2009/system/200904/1542.html 把linux的man手册转化为windows下可读的格式 我也是一个Linux学习 ...
- 委托到Lambda的进化: ()=> {} 这个lambda表达式就是一个无参数的委托及具体方法的组合体。
1.原始的委托 (.net 1.0) using System; using System.Collections.Generic; using System.ComponentModel; usin ...