Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
IPv6 アドレス文字列があります: 2001:1:0:0:10:0:10:10
IPV6 文字列の短い形式として表現したい: 2001:1::10:0:10:10
これを行うためのJavaメソッドを知っている人はいますか?
場合によってはさまざまな方法で短縮できるため、おそらくJava APIにはそのような機能はありません。手動で行うことができます:
Inet6Address.getByName("1080::8:800:200C:417A").replaceFirst("(:0)+:", "::");
しかし、私はそれをうまくテストしませんでした。このコードが間違っている場合もあります。