{"id":50925,"date":"2017-10-05T15:00:48","date_gmt":"2017-10-05T12:00:48","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=50925"},"modified":"2019-03-12T11:16:56","modified_gmt":"2019-03-12T09:16:56","slug":"java-nio-socketchannel-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/","title":{"rendered":"Java Nio SocketChannel Example"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\">SocketChannel<\/span> is a selectable channel belonging to the <code>java.nio.channels<\/code> package and is used for reading or writing the stream-oriented data. In this tutorial, we learn how to use the <code>SocketChannel<\/code> and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;\n<\/p>\n<h2>1. Introduction<\/h2>\n<p>Java Nio was developed to allow the Java programmers implement the high-speed input-output operations without using the custom native code. Nio moves the time-taking I\/O activities like filling, namely and draining buffers etc back into the operating system, thus allows the great increase in the operational speed.<\/p>\n<h3>1.1 Java Nio Components<\/h3>\n<p>The Java Nio classes are contained in the <code>java.nio<\/code> package and it is important to understand that the Nio subsystem does not replace the existing stream-based I\/O classes available in <code>java.io<\/code> package. The important Nio classes are grouped under different categories that are shown below:<\/p>\n<p><figure id=\"attachment_50926\" aria-describedby=\"caption-attachment-50926\" style=\"width: 573px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50926\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-3.jpg\" alt=\"Fig. 1: Nio Components\" width=\"573\" height=\"355\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-3.jpg 573w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-3-300x186.jpg 300w\" sizes=\"(max-width: 573px) 100vw, 573px\" \/><\/a><figcaption id=\"caption-attachment-50926\" class=\"wp-caption-text\">Fig. 1: Nio Components<\/figcaption><\/figure><\/p>\n<p>Let us understand the important classes contained in these groups.<\/p>\n<table>\n<tbody>\n<tr>\n<th>Package<\/th>\n<th>Purpose<\/th>\n<\/tr>\n<tr>\n<td><code>java.nio<\/code><\/td>\n<td>It is a top-level package for NIO system. The various types of buffers are encapsulated by this NIO system.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.charset<\/code><\/td>\n<td>It encapsulates the character sets and also supports the encoding and the decoding operation that converts the characters to bytes and bytes to characters.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.charset.spi<\/code><\/td>\n<td>It supports the service provider for the character sets.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.channels<\/code><\/td>\n<td>It supports the channel which is essentially open for the I\/O connections.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.channels.spi<\/code><\/td>\n<td>It supports the service providers for the channels.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.file<\/code><\/td>\n<td>It provides the support for the files.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.file.spi<\/code><\/td>\n<td>It supports the service providers for the file system.<\/td>\n<\/tr>\n<tr>\n<td><code>java.nio.file.attribute<\/code><\/td>\n<td>It provides the support for the file attributes.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.2 Java Nio Channels<\/h3>\n<p>In Java Nio, <strong>Channels<\/strong> are used for the input-output transfers. <span style=\"text-decoration: underline;\">A channel is like a tube that transports the data between a buffer and an entity at the other end<\/span>. A channel reads the data from an entity and places it in the buffer blocks for consumption. The developers then write the data to the buffer blocks so that it can be transported by the channel to the other end.<\/p>\n<p>Channels are the gateway provided by the Java Nio package to access the native input-output mechanism. Developers should use <em>buffers<\/em> to interact with the channels and to perform the input-output operations where these buffers act as the endpoints provided by the channels to send and receive the data.<\/p>\n<p><figure id=\"attachment_50928\" aria-describedby=\"caption-attachment-50928\" style=\"width: 520px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-5.jpeg\"><img decoding=\"async\" class=\"size-full wp-image-50928\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-5.jpeg\" alt=\"Fig. 2: Nio Channels\" width=\"520\" height=\"440\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-5.jpeg 520w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-architecture-diagram-5-300x254.jpeg 300w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/a><figcaption id=\"caption-attachment-50928\" class=\"wp-caption-text\">Fig. 2: Nio Channels<\/figcaption><\/figure><\/p>\n<h4>1.2.1 Channel Characteristics<\/h4>\n<ul>\n<li>Unlike streams, channels are two-way in nature and can perform both, read and write operations<\/li>\n<li>A channel reads the data into a buffer and writes the data from a buffer<\/li>\n<li>A channel can even perform the asynchronous read and write operations<\/li>\n<li>A non-blocking channel does not put the invoking thread in the sleep mode<\/li>\n<li>Stream-oriented channels like sockets can only be placed in the non-blocking mode<\/li>\n<li>The data can be transferred from one channel to another if any one of the channels is a <code>FileChannel<\/code><\/li>\n<\/ul>\n<h4>1.2.2 Channel Classes<\/h4>\n<p>Below are the two major types of channel classes provided as an implementation in the Java Nio package:<\/p>\n<ul>\n<li><code>FileChannel<\/code>: These are the File-based read\/write channels that cannot be placed in a non-blocking mode<\/li>\n<li><code>SocketChannel<\/code>: The Java Nio Socket Channel is used for connecting a channel with a TCP network socket. It is equivalent to the Java Networking Sockets used in the network programming. There are two methods available in the Java Nio package for creating a <code>SocketChannel<\/code> i.e. <code>ServerSocketChannel<\/code> and the <code>DatagramChannel<\/code>. Do note, <code>SocketChannel<\/code> are the selectable channels that can easily operate in the non-blocking mode<\/li>\n<\/ul>\n<p>Now, open up the Eclipse IDE and let\u2019s see how to implement the socket channel with Java Nio package!<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h2>2. Java Nio Socket Channel Example<\/h2>\n<h3>2.1 Tools Used<\/h3>\n<p>We are using Eclipse Kepler SR2, JDK 8 and Maven. Having said that, we have tested the code against JDK 1.7 and it works well.<\/p>\n<h3>2.2 Project Structure<\/h3>\n<p>Firstly, let\u2019s review the final project structure, in case you are confused about where you should create the corresponding files or folder later!<\/p>\n<p><figure id=\"attachment_50929\" aria-describedby=\"caption-attachment-50929\" style=\"width: 236px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50929\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-guide-1.jpg\" alt=\"Fig. 3: Java Nio Socket Channel Project Structure\" width=\"236\" height=\"289\"><\/a><figcaption id=\"caption-attachment-50929\" class=\"wp-caption-text\">Fig. 3: Java Nio Socket Channel Project Structure<\/figcaption><\/figure><\/p>\n<h3>2.3 Project Creation<\/h3>\n<p>This section will demonstrate on how to create a Java-based Maven project with Eclipse. In Eclipse IDE, go to <code>File -&gt; New -&gt; Maven Project<\/code>.<\/p>\n<p><figure id=\"attachment_50930\" aria-describedby=\"caption-attachment-50930\" style=\"width: 651px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50930\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-1.jpg\" alt=\"Fig. 4: Create Maven Project\" width=\"651\" height=\"607\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-1.jpg 651w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-1-300x280.jpg 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><figcaption id=\"caption-attachment-50930\" class=\"wp-caption-text\">Fig. 4: Create Maven Project<\/figcaption><\/figure><\/p>\n<p>In the New Maven Project window, it will ask you to select project location. By default, &#8216;Use default workspace location&#8217; will be selected. Select the &#8216;Create a simple project (skip archetype selection)&#8217; checkbox and just click on next button to proceed.<\/p>\n<p><figure id=\"attachment_50931\" aria-describedby=\"caption-attachment-50931\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50931\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-2.jpg\" alt=\"Fig. 5: Project Details\" width=\"804\" height=\"541\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-2.jpg 804w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-2-300x202.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-2-768x517.jpg 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><figcaption id=\"caption-attachment-50931\" class=\"wp-caption-text\">Fig. 5: Project Details<\/figcaption><\/figure><\/p>\n<p>It will ask you to &#8216;Enter the group and the artifact id for the project&#8217;. We will input the details as shown in the below image. The version number will be by default: <code>0.0.1-SNAPSHOT<\/code>.<\/p>\n<p><figure id=\"attachment_50932\" aria-describedby=\"caption-attachment-50932\" style=\"width: 596px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50932\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-3.jpg\" alt=\"Fig. 6: Archetype Parameters\" width=\"596\" height=\"541\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-3.jpg 596w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-3-300x272.jpg 300w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/a><figcaption id=\"caption-attachment-50932\" class=\"wp-caption-text\">Fig. 6: Archetype Parameters<\/figcaption><\/figure><\/p>\n<p>Click on Finish and the creation of a maven project is completed. If you observe, it has downloaded the maven dependencies and a <code>pom.xml<\/code> file will be created. It will have the following code:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\t&lt;groupId&gt;JavaNioSocketChannel&lt;\/groupId&gt;\n\t&lt;artifactId&gt;JavaNioSocketChannel&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n\t&lt;packaging&gt;jar&lt;\/packaging&gt;\n&lt;\/project&gt;\n<\/pre>\n<p>Developers can start adding the dependencies that they want like JUnit etc. Let\u2019s start building the application!<\/p>\n<h2>3. Application Building<\/h2>\n<p>Below are the steps involved in developing this application.<\/p>\n<h3>3.1 Java Class Creation<\/h3>\n<p>Let\u2019s create the required Java files. Right-click on <code>src\/main\/java<\/code> folder, <code>New -&gt; Package<\/code>.<\/p>\n<p><figure id=\"attachment_50933\" aria-describedby=\"caption-attachment-50933\" style=\"width: 680px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50933\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-4.jpg\" alt=\"Fig. 7: Java Package Creation\" width=\"680\" height=\"656\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-4.jpg 680w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-4-300x289.jpg 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><figcaption id=\"caption-attachment-50933\" class=\"wp-caption-text\">Fig. 7: Java Package Creation<\/figcaption><\/figure><\/p>\n<p>A new pop window will open where we will enter the package name as: <code>com.jcg.java.nio<\/code>.<\/p>\n<p><figure id=\"attachment_50934\" aria-describedby=\"caption-attachment-50934\" style=\"width: 516px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50934\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-5.jpg\" alt=\"Fig. 8: Java Package Name (com.jcg.java.nio)\" width=\"516\" height=\"425\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-5.jpg 516w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-5-300x247.jpg 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/a><figcaption id=\"caption-attachment-50934\" class=\"wp-caption-text\">Fig. 8: Java Package Name (com.jcg.java.nio)<\/figcaption><\/figure><\/p>\n<p>Once the package is created in the application, we will need to create the implementation classes. Right-click on the newly created package: <code>New -&gt; Class<\/code>.<\/p>\n<p><figure id=\"attachment_50935\" aria-describedby=\"caption-attachment-50935\" style=\"width: 669px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50935\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-6.jpg\" alt=\"Fig. 9: Java Class Creation\" width=\"669\" height=\"654\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-6.jpg 669w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-6-300x293.jpg 300w\" sizes=\"(max-width: 669px) 100vw, 669px\" \/><\/a><figcaption id=\"caption-attachment-50935\" class=\"wp-caption-text\">Fig. 9: Java Class Creation<\/figcaption><\/figure>[ulp id=&#8217;lQeyBcYaL5DqTMXI&#8217;]<\/p>\n<p>A new pop window will open and enter the file name as: <code>FileReceiver<\/code>. The receiver class will be created inside the package: <code>com.jcg.java.nio<\/code>.<\/p>\n<p><figure id=\"attachment_50936\" aria-describedby=\"caption-attachment-50936\" style=\"width: 533px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-7.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50936\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-7.jpg\" alt=\"Fig. 10: Java Class (FileReceiver.java)\" width=\"533\" height=\"628\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-7.jpg 533w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-7-255x300.jpg 255w\" sizes=\"(max-width: 533px) 100vw, 533px\" \/><\/a><figcaption id=\"caption-attachment-50936\" class=\"wp-caption-text\">Fig. 10: Java Class (FileReceiver.java)<\/figcaption><\/figure><\/p>\n<p>Repeat the step (i.e. Fig. 9) and enter the filename as <code>FileSender<\/code>. The sender class will be created inside the package: <code>com.jcg.java.nio<\/code>.<\/p>\n<p><figure id=\"attachment_50937\" aria-describedby=\"caption-attachment-50937\" style=\"width: 533px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-8.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50937\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-8.jpg\" alt=\"Fig. 11: Java Class (FileSender.java)\" width=\"533\" height=\"629\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-8.jpg 533w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-guide-8-254x300.jpg 254w\" sizes=\"(max-width: 533px) 100vw, 533px\" \/><\/a><figcaption id=\"caption-attachment-50937\" class=\"wp-caption-text\">Fig. 11: Java Class (FileSender.java)<\/figcaption><\/figure><\/p>\n<h4>3.1.1 Implementation of Receiver Class<\/h4>\n<p>The receiver class is used to receive the file from an entity (i.e. read from the socket channel). Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>FileReceiver.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jcg.java.nio;\n\nimport java.io.IOException;\nimport java.net.InetSocketAddress;\nimport java.nio.ByteBuffer;\nimport java.nio.channels.FileChannel;\nimport java.nio.channels.ServerSocketChannel;\nimport java.nio.channels.SocketChannel;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.nio.file.StandardOpenOption;\nimport java.util.EnumSet;\n\npublic class FileReceiver {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tFileReceiver server = new FileReceiver();\n\t\tSocketChannel socketChannel = server.createServerSocketChannel();\n\t\tserver.readFromSocketChannel(socketChannel);\n\t}\n\n\tprivate void readFromSocketChannel(SocketChannel socketChannel) throws IOException {\n\t\t\/\/ Receiver File Location\n\t\tString filePath =\"receivedConfig\/sample.txt\";\n\n\t\tPath path = Paths.get(filePath);\n\t\tFileChannel fileChannel = FileChannel.open(path, \n\t\t\t\tEnumSet.of(StandardOpenOption.CREATE, \n\t\t\t\t\t\tStandardOpenOption.TRUNCATE_EXISTING,\n\t\t\t\t\t\tStandardOpenOption.WRITE)\n\t\t\t\t);\t\t\n\n\t\t\/\/ Allocate a ByteBuffer\n\t\tByteBuffer buffer = ByteBuffer.allocate(1024);\n\t\twhile(socketChannel.read(buffer) &gt; 0) {\n\t\t\tbuffer.flip();\n\t\t\tfileChannel.write(buffer);\n\t\t\tbuffer.clear();\n\t\t}\n\t\tfileChannel.close();\n\t\tSystem.out.println(\"Received File Successfully!\");\n\t\tsocketChannel.close();\n\t}\n\n\tprivate SocketChannel createServerSocketChannel() throws IOException {\n\t\tServerSocketChannel serverSocket = null;\n\t\tSocketChannel client = null;\n\t\tserverSocket = ServerSocketChannel.open();\n\t\tserverSocket.socket().bind(new InetSocketAddress(9000));\n\t\tclient = serverSocket.accept();\n\n\t\tSystem.out.println(\"Connection Established . .?= \" + client.getRemoteAddress());\n\t\treturn client;\n\t}\n}\n<\/pre>\n<h4>3.1.2 Implementation of Sender Class<\/h4>\n<p>The sender class is used to read the file from a disk and send it across the socket channel so that it can be received by an entity present at the other end. Add the following code to it:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>FileSender.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">package com.jcg.java.nio;\n\nimport java.io.IOException;\nimport java.net.InetSocketAddress;\nimport java.net.SocketAddress;\nimport java.nio.ByteBuffer;\nimport java.nio.channels.FileChannel;\nimport java.nio.channels.SocketChannel;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\n\npublic class FileSender {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tFileSender client = new FileSender();\n\t\tSocketChannel socketChannel = client.createChannel();\n\t\tclient.sendFile(socketChannel);\n\t}\n\n\tprivate void sendFile(SocketChannel socketChannel) throws IOException {\t\t\n\t\t\/\/ Sender File Location\n\t\tString filePath =\"senderConfig\/sample.txt\";\n\n\t\t\/\/ Read a File From Disk. It's Filesize Is 1KB\n\t\tPath path = Paths.get(filePath);\n\t\tFileChannel inChannel = FileChannel.open(path);\n\n\t\t\/\/ Allocate a ByteBuffer\n\t\tByteBuffer buffer = ByteBuffer.allocate(1024);\n\t\twhile(inChannel.read(buffer) &gt; 0) {\n\t\t\tbuffer.flip();\n\t\t\tsocketChannel.write(buffer);\n\t\t\tbuffer.clear();\n\t\t}\n\t\tsocketChannel.close();\n\t}\n\n\tprivate SocketChannel createChannel() throws IOException {\n\t\tSocketChannel socketChannel = SocketChannel.open();\n\t\tSocketAddress socketAddr = new InetSocketAddress(\"localhost\", 9000);\n\t\tsocketChannel.connect(socketAddr);\n\t\treturn socketChannel;\n\t}\n}<\/pre>\n<h2>4. Run the Application<\/h2>\n<p>To run the Java Nio application, Right-click on the <code>FileReceiver<\/code> class <code>-&gt; Run As -&gt; Java Application<\/code>. Follow the similar step and execute the <code>FileSender<\/code> class. Developers can debug the example and see what happens after every step!<\/p>\n<p><figure id=\"attachment_50938\" aria-describedby=\"caption-attachment-50938\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-deploy-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50938\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-deploy-guide-3.jpg\" alt=\"Fig. 12: Run Application\" width=\"849\" height=\"369\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-deploy-guide-3.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-deploy-guide-3-300x130.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-deploy-guide-3-768x334.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-50938\" class=\"wp-caption-text\">Fig. 12: Run Application<\/figcaption><\/figure><\/p>\n<h2>5. Project Demo<\/h2>\n<p>When developers run the above program, the new file will be written in the project\u2019s <code>receivedConfig\/<\/code> directory and the code shows the following status as output.<\/p>\n<p><figure id=\"attachment_50940\" aria-describedby=\"caption-attachment-50940\" style=\"width: 170px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-demo-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-50940\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/java-socket-channel-example-project-structure-demo-guide-2.jpg\" alt=\"Fig. 13: Receiver Output\" width=\"170\" height=\"127\"><\/a><figcaption id=\"caption-attachment-50940\" class=\"wp-caption-text\">Fig. 13: Receiver Output<\/figcaption><\/figure><\/p>\n<p>That\u2019s all for this post. Happy Learning!!<\/p>\n<h2>6. Conclusion<\/h2>\n<p>This tutorial uses a simple example to illustrate <span style=\"text-decoration: underline;\">SocketChannel\u2019s<\/span> functionality and helps developers understand the basic configuration required to achieve this operation. That\u2019s all for this tutorial and I hope this article served you whatever you were looking for.<\/p>\n<h2>7. Download the Eclipse Project<\/h2>\n<p>This was an example of Java Nio for the beginners.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/10\/JavaNioSocketChannel.zip\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>JavaNioSocketChannel<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>SocketChannel is a selectable channel belonging to the java.nio.channels package and is used for reading or writing the stream-oriented data. In this tutorial, we learn how to use the SocketChannel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &hellip;<\/p>\n","protected":false},"author":119,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[189,774,1555,1554,1557,1043,236,1250],"class_list":["post-50925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nio","tag-core-java-2","tag-java-8","tag-java-nio-file-files","tag-java-nio-file-path","tag-java-nio-file-paths","tag-nio","tag-socket-2","tag-socketchannel"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Nio SocketChannel Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this tutorial, we learn how to use the Socket Channel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Nio SocketChannel Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we learn how to use the Socket Channel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-05T12:00:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-12T09:16:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"Java Nio SocketChannel Example\",\"datePublished\":\"2017-10-05T12:00:48+00:00\",\"dateModified\":\"2019-03-12T09:16:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\"},\"wordCount\":1253,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"core java\",\"Java 8\",\"java.nio.file.Files\",\"java.nio.file.Path\",\"java.nio.file.Paths\",\"nio\",\"socket\",\"SocketChannel\"],\"articleSection\":[\"nio\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\",\"name\":\"Java Nio SocketChannel Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2017-10-05T12:00:48+00:00\",\"dateModified\":\"2019-03-12T09:16:56+00:00\",\"description\":\"In this tutorial, we learn how to use the Socket Channel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"nio\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/nio\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Java Nio SocketChannel Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Nio SocketChannel Example - Java Code Geeks","description":"In this tutorial, we learn how to use the Socket Channel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/","og_locale":"en_US","og_type":"article","og_title":"Java Nio SocketChannel Example - Java Code Geeks","og_description":"In this tutorial, we learn how to use the Socket Channel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-10-05T12:00:48+00:00","article_modified_time":"2019-03-12T09:16:56+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"Java Nio SocketChannel Example","datePublished":"2017-10-05T12:00:48+00:00","dateModified":"2019-03-12T09:16:56+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/"},"wordCount":1253,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["core java","Java 8","java.nio.file.Files","java.nio.file.Path","java.nio.file.Paths","nio","socket","SocketChannel"],"articleSection":["nio"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/","name":"Java Nio SocketChannel Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2017-10-05T12:00:48+00:00","dateModified":"2019-03-12T09:16:56+00:00","description":"In this tutorial, we learn how to use the Socket Channel and how it is used for reading or writing the stream-oriented data by using the TCP based protocol.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-socketchannel-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"nio","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/nio\/"},{"@type":"ListItem","position":5,"name":"Java Nio SocketChannel Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/50925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=50925"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/50925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=50925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=50925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=50925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}