Advanced networks Assignment 2

1. Given the address, find the hostname using java programming language.
mail@pastecode.io avatar
unknown
plain_text
2 years ago
548 B
1
Indexable
Never
package Assingment2;
import java.net.*;
import java.util.Scanner;

public class HostnameSearch {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try{
            System.out.println("Input some website");
            String si = sc.nextLine();
            sc.close();
            InetAddress address = InetAddress.getByName(si);
            System.out.println(address);
        }catch(UnknownHostException ex){
            System.out.println("Could not find");
        }
    }  
}