import java.net.InetAddress; import java.net.UnknownHostException; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String ip = scanner.next(); String address = scanner.next(); // 将IP地址转换成字节数组 byte[] bytes; try { bytes = InetAddress.getByName(ip).getAddress(); } catch (UnknownHostException e) { e.printStackTrace(); return; } // 将字节数组转换成长整数 long result = 0; for (byte b : bytes) { result <<= 8; result |= b & 0xFF; } // 输出结果 System.out.println(result); System.out.println(InetAddress.getByName(address).getHostAddress()); } } }