Java - Getting Computer Name


public class GetComputerName {

    public static void main(String args[]) {
        try {
            String computerName = InetAddress.getLocalHost().getHostName();
            System.out.println(computerName);
        } catch (Exception e) {
            System.out.println("Exception caught =" + e.getMessage());
        }
    }
}

Post a Comment

0 Comments