【问题标题】:I'm trying to make a tool in which you can input an IP address [duplicate]我正在尝试制作一个可以输入IP地址的工具[重复]
【发布时间】:2017-05-10 08:05:27
【问题描述】:

我正在尝试通过在行中输入 IP 地址来创建 InetAddress 对象

InetAddress inetAddress=InetAddress.getByAddress(1.1.1.1); //random IP address for this post

据我从 oracle 的网站了解,它应该是这样的,但我收到一个错误,整行带有红色下划线,它说

"')' 预期

不兼容的类型:double 无法转换为 byte[]"

关于如何解决此问题的任何建议?我输入的 IP 地址有误吗?

【问题讨论】:

    标签: java


    【解决方案1】:

    它期望地址为byte[]。试试:

    InetAddress.getByAddress(new byte[]{1,1,1,1})
    

    【讨论】:

    • InetAddress.getByName("1.1.1.1")
    猜你喜欢
    • 2021-08-11
    • 1970-01-01
    • 2013-12-16
    • 2019-02-20
    • 1970-01-01
    • 1970-01-01
    • 2013-01-12
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多