Home » Core Java » net

net

java.net.CookieManager Example

A Cookie is a small piece of data (such as browsing activity) sent from a website and stored in a user’s web browser while the user is browsing that website. In Java 5, an abstract class java.net.Cookiehandler was introduced which is responsible for storing and retrieving cookies. However, there was not an actual implementation of that class. In Java 6, ...

Read More »

java.net.URLDecoder Example

URLDecoder is a utility class for HTML form decoding. This class contains static methods for decoding a String from the application/x-www-form-urlencoded MIME format. Project Environment This example was implemented using the following tools : Eclipse 4.3 (Kepler) JDK 1.4 or greater 1. Example of URLDecoder We are going to decode string in this example. Create a java class named URLDecoderExample ...

Read More »

java.net.CookieStore Example

A CookieStore is an interface that represents a storage area for cookies.CookieManager adds the cookies to the CookieStore for every HTTP response and retrieves cookies from the CookieStore for every HTTP request. You can customize CookieStore to save cookies so that they can be used even if the Java Virtual Machine is restarted. In this example we are going to retrieve ...

Read More »

Java.net.URLClassLoader Example

In this example, we shall see how we can use the java.net.URLClassLoader Class in the java.net package for loading the classes dynamically. The URLClassLoader class Loads the classes and other resources at runtime from a directory or a JAR file. It has constructors that accept an array of URL class, URL[] and delegating parent Class-Loader, optionally.         ...

Read More »

java.net.MulticastSocket Example

In this example we are going to explain how to use MulticastSocket in Java, in order to enable a server to easily send information to multiple clients, which are all connected to the same port and address. We will describe the whole process, by creating both the server and the client, and guide you through the main concepts that need to be understood to ...

Read More »

java.net.HttpCookie Example

In this example we shall show you how to make use of HttpCookie class, HttpCookie is used to implement the HTTP state management mechanism which specifies a way to create a stateful session with HTTP requests and responses. Generally, HTTP request/response pairs are independent of each other. However, the state management mechanism enables clients and servers to exchange state information and put ...

Read More »

java.net.NetworkInterface Example

In this example we are going to examine the java.net.NetworkInterface class. This class allows us to programmatically gather information about our network interfaces, and it is especially useful in cases where we need to do some programming using networks and connections. We will explain some of the most important methods and usage of this class and show the retrieved information.   ...

Read More »

java.net.JarURLConnection Example

In this example we shall show you how to make use of JarURLConnection class, This class establishes a connection to a jar URL using the JAR protocol. A JarURLConnection instance can refer to either a JAR archive file or to an entry of such a file. jar URLs are specified as follows: jar:{archive-url}!/{entry} where !/ is called a separator. This separator ...

Read More »

java.net.Inet4Address Example

In this example we will discuss about Inet4Address and its usage. Inet4Address represents an Internet Protocol version 4 (IPv4) address. Inet4Address is a subclass of InetAddress class, which represents either a 32-bit or 128-bit unsigned number used as an IP, the lower-level protocol on which protocols like UDP and TCP are built. The Inet4Address class exists since JDK1.4.     ...

Read More »

java.net.URLEncoder Example

In this example we shall show you how to make use of URLEncoder class. URLEncoder is a utility class for HTML form encoding, contains static methods for converting a string to the application/x-www-form-urlencoded MIME format. This class is very useful to encode URL query string values.         When encoding a string, the following rules apply: The alphanumeric ...

Read More »