Home » Core Java » net » Page 2

net

java.net.URLClassLoader Example

Bipartite Graph

In this example we shall show you how to make use of URLClassLoader, This class can be used to load a Class or a collection of classes that are accessible via URLs which referring to both JAR files and directories. Any URL that ends with a ‘/’ is assumed to refer to a directory. Otherwise, the URL is assumed to ...

Read More »

java.net.URISyntaxException – How to solve URISyntaxException

Bipartite Graph

In this example we are going to talk about java.net.URISyntaxException. This is a checked exception that occurs when you are trying to parse a string that represents a URI, but it doesn’t have the correct format. 1. A simple example of URISyntaxException Let’s see a program that parses a legal URI: URISyntaxExceptioExample.java:   package com.javacodegeeks.core.net.urisyntaxexception; import java.net.URI; import java.net.URISyntaxException; public ...

Read More »

java.net.SocketException – How to solve SocketException

Bipartite Graph

In this example we are going to talk about java.net.SocketException. This is a subclass of IOException so it’s a checked exception. It is the most general exception that signals a problem when trying to open or access a socket. As you might already know, it’s strongly advised to use the most “specific” socket exception class that designates the problem more ...

Read More »

java.net.URL Example

Bipartite Graph

In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer to a “resource” on the World Wide Web. An URL is a text string that identifies a resource, tells where to find it, and specifies a method for communicating with it or retrieving it from its ...

Read More »

java.net.ConnectException – How to solve Connect Exception

Bipartite Graph

In this example we are going to discuss about one of the most common exceptions you will come across when dealing with network programming in Java: ConnectException. ConnectException is a subclass of SocketException, and that alone reveals that it is meant to inform you about an error that occurred when you tried to create or access a socket. To be ...

Read More »

How to get IP address in Java using InetAddress

Bipartite Graph

An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. The designers of the Internet Protocol defined an IPv4 address as a 32-bit number. In this tutorial we are going to see how can you get the IP Address that is ...

Read More »

Access password protected URL with Authenticator

Bipartite Graph

With this example we are going to demonstrate how to access a password protected URL using the Authenticator Class. The class Authenticator represents an object that knows how to obtain authentication for a network connection. Usually, it will do this by prompting the user for information. Applications use this class by overriding getPasswordAuthentication() in a sub-class. This method will typically ...

Read More »