IP address of localhost in java

This example shows you how to get IP address of localhost in java. Below is the example code of getting IP address of localhost in java: package com.java.connect.net; import java.net.InetAddress; import java.net.UnknownHostException; //IP address of localhost in java public class NetworkIPAddressExample { public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost(); String […]

Continue reading


How to create an URL object in java

This example shows you how to create a URL object in java and read the content of that URL. Below is the example code of creating URL object and reading the content of that URL. package com.java.connect.net; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; //How to create an URL object in java […]

Continue reading


How to get Image by URL in java

This example shows you how to get the Image file from an URL in java. Below is the example code of getting the Image file from an URL in java. package com.java.connect.net; import java.io.IOException; import java.net.URL; import java.net.URLConnection; // Get Image by URL in java public class URLImageReadExample { public static void main(String[] args) throws […]

Continue reading


How to check open port in java

This example shows you how to check the open port in localhost using java. Below is the example code of checking open port in java for a host name. package com.java.connect.net; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; //Check open port in java public class NetworkOpenPortExample { public static void main(String[] args) throws Exception { // […]

Continue reading