gpt4 book ai didi

相当于 ntohll 函数的 Java

转载 作者:太空宇宙 更新时间:2023-11-04 15:42:16 24 4
gpt4 key购买 nike

在 Java 中是否有等同于 ntohll C++ 函数的函数?

ntohll 的引用可以在这里找到:ntohll function .

问题是我需要将 64 位长从 TCP/IP 网络顺序转换为小尾数法长。

最佳答案

ntohll的java等价函数是:long等价于64位

    import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public long ntohll(long convert)
{
ByteBuffer bbuf = ByteBuffer.allocate(8);
bbuf.order(ByteOrder.BIG_ENDIAN);
bbuf.putLong(convert);
bbuf.order(ByteOrder.LITTLE_ENDIAN);
return bbuf.getLong(0);
}

关于相当于 ntohll 函数的 Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21261286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com