What is the Java

Hello Friends I will to talk about the What is the Java

Article gives an overview of the key parts of the NIO API you know trying to use it.

What is the NIO API?


NIO (Network IO Interface) is a Java library for the network programming language NIO and locking resources.

it’s written in Java it can be share with other programs.
In the Java world, the library that everyone will use is the Nutty
platform, for practical purposes this is a really good option.


what does it look like?


Enough intro, let’s dive into some code.


OK, let’s start the NIO service and test it out. I’m using the Apache Maven

distribution I’m lazy and want to keep it simple.


Make sure you have the Netty framework and the JDK
If you don’t have t two, make sure you download and compile them starting.


After installation you can start Netty from the classpath.
The snippet starts the Netty service, you
can just as well use a start method on the NIO interface:

mvn boot:run

Let’s see how the NIO API works:

java -cp ‘netty-4.1.0.jar’ -jar nio-example.jar

How to send and receive data from a socket

This is the first and most basic of all IO objects.
It receives and sends data from a socket.

a class that contains some functionality that’s very useful for

Let’s see how the NIO API works:

We open an http connection we call the open method on the http class.


Let’s take a closer look at what these methods do:

The method open takes two parameters:
The first is a HTTP protocol, the second is the HTTP response object,
in this the URL and the response text.

The next three methods on the interface are the most useful.

NIO.start

This method is the core of NIO

. what called, it takes a stream of arguments.
The first parameter is a stream of arguments that contain the HTTP request arguments and the URL.
The second parameter is the list of responses that you want to send back to the HTTP client.

NIO.shutdown

What this method is

java -cp ‘netty-4.1.0.jar’ -jar nio-example.jar

The above command will run the Nettie server that can be accesse from a browser.

How to send and receive data from a socket

This is the first and most basic of all IO objects.
It receives and sends data from a socket. Let’s see how to work with it.

Leave a Comment