{"id":47434,"date":"2017-06-15T11:00:02","date_gmt":"2017-06-15T08:00:02","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=47434"},"modified":"2019-03-12T11:31:40","modified_gmt":"2019-03-12T09:31:40","slug":"java-nio-bytebuffer-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/","title":{"rendered":"Java Nio ByteBuffer Example"},"content":{"rendered":"<p>This article is a tutorial on demonstrating the usage of the Java Nio <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a>. All examples are done in the form of unit tests to easily prove the expectations of the API.<br \/>\n&nbsp;<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>The&nbsp;<a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a>&nbsp;class is an abstract class which also happens to extend&nbsp;<a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/Buffer.html\">Buffer<\/a> and implement <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/lang\/Comparable.html\">Comparable<\/a>. A Buffer is simply a linear finite sized container for data of a certain primitive type. It exhibits the following properties:<\/p>\n<ul>\n<li>capacity: the number of elements it contains<\/li>\n<li>limit &nbsp; &nbsp; &nbsp;:&nbsp;the index of where the data it contains ends<\/li>\n<li>position : the next element to be read or written<\/li>\n<\/ul>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> has these properties but also displays a host of semantic properties of it&#8217;s own. According to the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> API the abstraction defines six categories of operations. They are:<\/p>\n<ol>\n<li><code>get(...)<\/code> and <code>put(...)<\/code>operations that operate relatively (in terms of the current position) and absolutely (by supplying an index)<\/li>\n<li>bulk <code>get(...)<\/code>operation done relatively (in terms of the current position) which will get a number of bytes from the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> and place it into the argument <code>array<\/code>&nbsp;supplied to the <code>get(...)<\/code>&nbsp;operation<\/li>\n<li>bulk <code>put(...)<\/code>operation done absolutely by supplying an <code>index<\/code>&nbsp;and the content to be inserted<\/li>\n<li>absolute and relative <code>get(...)<\/code>and <code>put(...)<\/code>&nbsp;operations that get and put data of a specific primitive type, making it convenient to work with a specific primitive type when interacting with the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a><\/li>\n<li>creating a &#8220;view buffer&#8217; or view into the underlying <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> by proxying the underlying data with a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/Buffer.html\">Buffer<\/a> of a specific primitive type<\/li>\n<li>compacting, duplicating and slicing a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a><\/li>\n<\/ol>\n<p>A <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> is implemented by the <code>HeapByteBuffer<\/code> and <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/MappedByteBuffer.html\">MappedByteBuffer<\/a> abstractions. <code>HeapByteBuffer<\/code> further specializes into <code>HeapByteBufferR<\/code> (R being read-only), which will very conveniently throw a&nbsp;<a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ReadOnlyBufferException.html\">ReadOnlyBufferException<\/a> and should you try to mutate it via it&#8217;s API. The <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/MappedByteBuffer.html\">MappedByteBuffer<\/a> is an abstract class which is implemented by <code>DirectByteBuffer<\/code>. All of the<code>HeapByteBuffer<\/code> implementations are allocated on the heap (obviously) and thus managed by the JVM.<\/p>\n<h2>2. Technologies used<\/h2>\n<p>The example code in this article was built and run using:<\/p>\n<ul>\n<li>Java 1.8.101 (1.8.x will do fine)<\/li>\n<li>Maven 3.3.9 (3.3.x will do fine)<\/li>\n<li>Spring source tool suite 4.6.3 (Any Java IDE would work)<\/li>\n<li>Ubuntu 16.04 (Windows, Mac or Linux will do fine)<\/li>\n<\/ul>\n<h2>3. Overview<\/h2>\n<p>A ByteBuffer is created via the the two static factory methods:<\/p>\n<ul>\n<li><code>allocate(int)<\/code> this will allocate a <code>HeapByteBuffer<\/code>with the capacity specified by the <code>int<\/code> argument<\/li>\n<li><code>allocateDirect(int)<\/code> this will allocate a <code>DirectByteBuffer<\/code> with the capacity specified by the <code>int<\/code> argument<\/li>\n<\/ul>\n<p>The <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> class affords us the luxury of a fluent interface through much of it&#8217;s API, meaning most operations will return a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> result. This way we can obtain a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> by also wrapping a <code>byte []<\/code>, slicing a piece of another <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a>, duplicating an existing <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> and performing <code>get(...)<\/code>and <code>put(...)<\/code>operations against an existing <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a>. I encourage you to review the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> API to understand the semantics of it&#8217;s API.<\/p>\n<p>So why the distinction between direct and non-direct? It comes down to allowing the Operating System to access memory addresses contiguously for IO operations (hence being able to shove and extract data directly from the memory address) as opposed to leveraging the indirection imposed by the abstractions in the JVM for potentially non-contiguous memory spaces. Because the JVM cannot guarantee contiguous memory locations for <code>HeapByteBuffer<\/code> allocations the Operating System cannot natively shove and extract data into these types of <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a>. So generally the rule of thumb is should you be doing a lot of IO, then the best approach is to allocate directly and re-use the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a>. Be warned <code>DirectByteBuffer<\/code> instances are not subject to the GC.<\/p>\n<h2>4. Test cases<\/h2>\n<p>To ensure determinism we have been explicit about the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/charset\/Charset.html\">Charset<\/a> in use, therefore any encoding of bytes or decoding of bytes will use the explicit <code>UTF-16BE<\/code>&nbsp; <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/charset\/Charset.html\">Charset<\/a>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline;\"><em>Relative Get and Put operations Test cases<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight: [1]; wrap-lines: false\">public class RelativeGetPutTest extends AbstractTest {\n\n    @Test\n    public void get() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n\n        final byte a = buffer.get();\n        final byte b = buffer.get();\n\n        assertEquals(\"Buffer position invalid\", 2, buffer.position());\n        assertEquals(\"'H' not the first 2 bytes read\", \"H\", new String(new byte[] { a, b }, BIG_ENDIAN_CHARSET));\n    }\n\n    @Test\n    public void put() {\n        final ByteBuffer buffer = ByteBuffer.allocate(24);\n\n        buffer.put(\"H\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"e\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"l\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"l\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"o\".getBytes(BIG_ENDIAN_CHARSET));\n\n        buffer.put(\" \".getBytes(BIG_ENDIAN_CHARSET));\n\n        buffer.put(\"e\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"a\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"r\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"t\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"h\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.put(\"!\".getBytes(BIG_ENDIAN_CHARSET));\n\n        assertEquals(\"Buffer position invalid\", 24, buffer.position());\n        \n        buffer.flip();\n        assertEquals(\"Text data invalid\", \"Hello earth!\", byteBufferToString(buffer));\n    }\n\n    @Test\n    public void bulkGet() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        final byte[] output = new byte[10];\n\n        buffer.get(output);\n\n        assertEquals(\"Invalid bulk get data\", \"Hello\", new String(output, BIG_ENDIAN_CHARSET));\n        \n        assertEquals(\"Buffer position invalid\", 10, buffer.position());\n    }\n\n    @Test\n    public void bulkPut() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        final byte[] output = new String(\"earth.\").getBytes(BIG_ENDIAN_CHARSET);\n\n        buffer.position(12);\n        \n        buffer.put(output);\n\n        assertEquals(\"Buffer position invalid\", 24, buffer.position());\n        buffer.flip();\n        assertEquals(\"Text data invalid\", \"Hello earth.\", byteBufferToString(buffer));\n    }\n\n    @Test\n    public void getChar() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        \n        buffer.mark();\n        \n        final byte a = buffer.get();\n        final byte b = buffer.get();\n        \n        buffer.reset();\n\n        char value = buffer.getChar();\n\n        assertEquals(\"Buffer position invalid\", 2, buffer.position());\n        \n        assertEquals(\"'H' not the first 2 bytes read\", \"H\", new String(new byte[] { a, b }, BIG_ENDIAN_CHARSET));\n        assertEquals(\"Value and byte array not equal\", Character.toString(value), new String(new byte[] { a, b }, BIG_ENDIAN_CHARSET));\n    }\n    \n    @Test\n    public void putChar() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        \n        buffer.position(22);\n        \n        buffer.putChar('.');\n        \n        assertEquals(\"Buffer position invalid\", 24, buffer.position());        \n        \n        buffer.flip();        \n        assertEquals(\"Text data invalid\", \"Hello world.\", byteBufferToString(buffer));\n    }\n}\n<\/pre>\n<p>The above suite of test cases demonstrate relative <code>get()<\/code>and <code>put()<\/code>operations. These have a direct effect on certain <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> attributes (position and data). In addition to being able to invoke these operations with <code>byte<\/code> arguments or receive <code>byte<\/code> arguments we also demonstrate usage of the <code>putChar()<\/code>and <code>getChar(...)<\/code>methods which conveniently act on the matching primitive type in question. Please consult the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">API<\/a> for more of these convenience methods<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Absolute Get and Put operations Test cases<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight: [1]; wrap-lines: false\">public class AbsoluteGetPutTest extends AbstractTest {\n\n    @Test\n    public void get() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n\n        final byte a = buffer.get(0);\n        final byte b = buffer.get(1);\n\n        assertEquals(\"Buffer position invalid\", 0, buffer.position());\n        assertEquals(\"'H' not the first 2 bytes read\", \"H\", new String(new byte[] { a, b }, BIG_ENDIAN_CHARSET));\n    }\n\n    @Test\n    public void put() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n\n        final byte[] period = \".\".getBytes(BIG_ENDIAN_CHARSET);\n        int idx = 22;\n        for (byte elem : period) {\n            buffer.put(idx++, elem);\n        }\n\n        assertEquals(\"Position must remian 0\", 0, buffer.position());\n        assertEquals(\"Text data invalid\", \"Hello world.\", byteBufferToString(buffer));\n    }\n    \n    @Test\n    public void getChar() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        char value = buffer.getChar(22);\n\n        assertEquals(\"Buffer position invalid\", 0, buffer.position());\n        assertEquals(\"Invalid final character\", \"!\", Character.toString(value));\n    }\n    \n    @Test\n    public void putChar() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.putChar(22, '.');\n        \n        assertEquals(\"Buffer position invalid\", 0, buffer.position());        \n        assertEquals(\"Text data invalid\", \"Hello world.\", byteBufferToString(buffer));\n    }\n}\n<\/pre>\n<p>The above suite of test cases demonstrate usage of the absolute variants of the <code>get(...)<\/code>and <code>put(...)<\/code>operations. Interestingly enough, only the underlying data is effected (<code>put(...)<\/code>) as the position cursor is not mutated owing to the method signatures providing client code the ability to provide an index for the relevant operation. Again convenience methods which deal with the various primitive types are also provided and we demonstrate use of the <code>...Char(...)<\/code>variants thereof.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ViewBuffer Test cases<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight: [1]; wrap-lines: false\">public class ViewBufferTest extends AbstractTest {\n\n    @Test\n    public void asCharacterBuffer() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));        \n        final CharBuffer charBuffer = buffer.asCharBuffer();\n        \n        assertEquals(\"Buffer position invalid\", 0, buffer.position());\n        assertEquals(\"CharBuffer position invalid\", 0, charBuffer.position());\n        assertEquals(\"Text data invalid\", charBuffer.toString(), byteBufferToString(buffer));\n    }\n    \n    @Test\n    public void asCharacterBufferSharedData() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));        \n        final CharBuffer charBuffer = buffer.asCharBuffer();\n        \n        assertEquals(\"Buffer position invalid\", 0, buffer.position());\n        assertEquals(\"CharBuffer position invalid\", 0, charBuffer.position());\n        \n        final byte[] period = \".\".getBytes(BIG_ENDIAN_CHARSET);\n        int idx = 22;\n        for (byte elem : period) {\n            buffer.put(idx++, elem);\n        }\n        \n        assertEquals(\"Text data invalid\", \"Hello world.\", byteBufferToString(buffer));\n        assertEquals(\"Text data invalid\", charBuffer.toString(), byteBufferToString(buffer));\n    }\n}\n<\/pre>\n<p>In addition to the various convenience <code>get(...)<\/code>and <code>put(...)<\/code>methods that deal with the various primitive types <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> provides us with an assortment of methods that provide primitive <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> views of the underlying data eg: <code>asCharBuffer()<\/code>demonstrates exposing a Character Buffer view of the underlying data.[ulp id=&#8217;lQeyBcYaL5DqTMXI&#8217;]<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Miscellaneous ByteBuffer Test cases<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight: [1]; wrap-lines: false\">public class MiscBufferTest extends AbstractTest {\n\n    @Test\n    public void compact() {\n        final ByteBuffer buffer = ByteBuffer.allocate(24);\n        buffer.putChar('H');\n        buffer.putChar('e');\n        buffer.putChar('l');\n        buffer.putChar('l');\n        buffer.putChar('o');        \n        \n        buffer.flip();\n        buffer.position(4);\n        buffer.compact();\n        \n        assertEquals(\"Buffer position invalid\", 6, buffer.position());\n        \n        buffer.putChar('n');\n        buffer.putChar('g');\n        \n        assertEquals(\"Buffer position invalid\", 10, buffer.position());\n        buffer.flip();\n        assertEquals(\"Invalid text\", \"llong\", byteBufferToString(buffer));\n    }\n    \n    @Test\n    public void testDuplicate() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        final ByteBuffer duplicate = buffer.duplicate();\n        \n        assertEquals(\"Invalid position\", 0, duplicate.position());\n        assertEquals(\"Invalid limit\", buffer.limit(), duplicate.limit());\n        assertEquals(\"Invalid capacity\", buffer.capacity(), duplicate.capacity());\n        \n        buffer.putChar(22, '.');\n        \n        assertEquals(\"Text data invalid\", \"Hello world.\", byteBufferToString(buffer));\n        assertEquals(\"Text data invalid\",  byteBufferToString(duplicate), byteBufferToString(buffer));\n    }\n    \n    @Test\n    public void slice() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        buffer.position(12);\n        \n        final ByteBuffer sliced = buffer.slice();\n        assertEquals(\"Text data invalid\", \"world!\", byteBufferToString(sliced));\n        assertEquals(\"Invalid position\", 0, sliced.position());\n        assertEquals(\"Invalid limit\", buffer.remaining(), sliced.limit());\n        assertEquals(\"Invalid capacity\", buffer.remaining(), sliced.capacity());\n        \n        buffer.putChar(22, '.');\n        assertEquals(\"Text data invalid\", \"world.\", byteBufferToString(sliced));        \n    }\n    \n    @Test\n    public void rewind() {\n        final ByteBuffer buffer = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        \n        final byte a = buffer.get();\n        final byte b = buffer.get();\n        \n        assertEquals(\"Invalid position\", 2, buffer.position());\n        \n        buffer.rewind();\n        \n        assertEquals(\"Invalid position\", 0, buffer.position());\n        assertSame(\"byte a not same\", a, buffer.get());\n        assertSame(\"byte a not same\", b, buffer.get());\n    }\n    \n    @Test\n    public void compare() {\n        final ByteBuffer a = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        final ByteBuffer b = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        \n        assertTrue(\"a is not the same as b\", a.compareTo(b) == 0);\n    }\n    \n    @Test\n    public void compareDiffPositions() {\n        final ByteBuffer a = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        final ByteBuffer b = ByteBuffer.wrap(\"Hello world!\".getBytes(BIG_ENDIAN_CHARSET));\n        \n        a.position(2);\n        \n        assertTrue(\"a is the same as b\", a.compareTo(b) != 0);\n    }    \n}\n<\/pre>\n<h2>5. Summary<\/h2>\n<p>In this tutorial we learned a bit about <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a>, we understood how to create one, the various types, why we have the different types and when to use them as well as the core semantic operations defined by the abstraction.<\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a> are not thread safe and hence many operations on it, need to be guarded against to ensure that multiple threads do not corrupt the data or views thereon. Be wary of relative <code>get(...)<\/code>&nbsp;and <code>put(...)<\/code>&nbsp;operations as these do sneaky things like advancing the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a> position.<\/p>\n<p>Wrapping, slicing and duplicating all point to the <code>byte []<\/code> they wrapped or the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> they sliced \/ duplicated. Changes to the source input or the resulting <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a> will effect each other. Luckily with <code>slice(...)<\/code>and <code>duplicate(...)<\/code>the position, mark and limit cursors are independent.<\/p>\n<p>When toggling between reading data into a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> and writing the contents from that same <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> it is important to <code>flip()<\/code>the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> to ensure the <code>limit<\/code>&nbsp;is set to the current <code>position<\/code>, &nbsp;the current <code>position<\/code> is reset back to 0&nbsp;and the <code>mark<\/code>, if defined, is discarded. This will ensure the ensuing write will be able to write what was just read. Partial writes in this context can be guarded against by calling <code>compact()<\/code>right before the next iteration of read and is very elegantly demonstrated in the API under <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html#compact--\">compact<\/a>.<\/p>\n<p>When comparing <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a> the positions matter, ie: you can have segments of a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> that are identical and these compare favorably should the two <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffers<\/a>, in question, have the same position and limit (<code>bytesRemaining()<\/code>) during comparison.<\/p>\n<p>For frequent high volume IO operations a <code>DirectByteBuffer<\/code>&nbsp;should yield better results and thus should be preferred.<\/p>\n<p>Converting a <code>byte []<\/code>into a <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> can be accomplished by wrapping the <code>byte []<\/code>via the <code>wrap(...)<\/code>method. Converting back to a <code>byte []<\/code>is not always that straight forward. Using the convenient <code>array()<\/code>&nbsp;method on <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> only works if the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/nio\/ByteBuffer.html\">ByteBuffer<\/a> is backed by a <code>byte []<\/code>. This can be confirmed via the <code>hasArray()<\/code>method. A bulk <code>get(...)<\/code>&nbsp;into an applicably sized <code>byte []<\/code>&nbsp;is your safest bet, but be on the guard for sneaky side effects, ie: bumping the <code>position<\/code>cursor.<\/p>\n<h2>6. Download the source code<\/h2>\n<p>This was a Java Nio ByteBuffer tutorial<\/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\/06\/bytebuffer.zip\"><strong>Java Nio ByteBuffer tutorial<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the expectations of the API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1. Introduction The&nbsp;ByteBuffer&nbsp;class is an abstract class which also happens to extend&nbsp;Buffer and implement Comparable. &hellip;<\/p>\n","protected":false},"author":129,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[1043],"class_list":["post-47434","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nio","tag-nio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Nio ByteBuffer Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the\" \/>\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-bytebuffer-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Nio ByteBuffer Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-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-06-15T08:00:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-12T09:31:40+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=\"JJ\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@jeanjayvester1\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JJ\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 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-bytebuffer-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/\"},\"author\":{\"name\":\"JJ\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/af856abe55325eb35866dc62a821c1bc\"},\"headline\":\"Java Nio ByteBuffer Example\",\"datePublished\":\"2017-06-15T08:00:02+00:00\",\"dateModified\":\"2019-03-12T09:31:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/\"},\"wordCount\":1185,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"nio\"],\"articleSection\":[\"nio\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/\",\"name\":\"Java Nio ByteBuffer Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2017-06-15T08:00:02+00:00\",\"dateModified\":\"2019-03-12T09:31:40+00:00\",\"description\":\"This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-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-bytebuffer-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 ByteBuffer 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\/af856abe55325eb35866dc62a821c1bc\",\"name\":\"JJ\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9c7eb5a98aedd6421eb285eea1b5e8991789024a35e415108b292edb81a37c3f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9c7eb5a98aedd6421eb285eea1b5e8991789024a35e415108b292edb81a37c3f?s=96&d=mm&r=g\",\"caption\":\"JJ\"},\"description\":\"Jean-Jay Vester graduated from the Cape Peninsula University of Technology, Cape Town, in 2001 and has spent most of his career developing Java backend systems for small to large sized companies both sides of the equator. He has an abundance of experience and knowledge in many varied Java frameworks and has also acquired some systems knowledge along the way. Recently he has started developing his JavaScript skill set specifically targeting Angularjs and also bridged that skill to the backend with Nodejs.\",\"sameAs\":[\"http:\/\/examples.javacodegeeks.com\/\",\"https:\/\/za.linkedin.com\/in\/jean-jay-vester-b135906\",\"https:\/\/x.com\/jeanjayvester1\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/jean-vester\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Nio ByteBuffer Example - Java Code Geeks","description":"This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the","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-bytebuffer-example\/","og_locale":"en_US","og_type":"article","og_title":"Java Nio ByteBuffer Example - Java Code Geeks","og_description":"This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-06-15T08:00:02+00:00","article_modified_time":"2019-03-12T09:31:40+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":"JJ","twitter_card":"summary_large_image","twitter_creator":"@jeanjayvester1","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"JJ","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/"},"author":{"name":"JJ","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/af856abe55325eb35866dc62a821c1bc"},"headline":"Java Nio ByteBuffer Example","datePublished":"2017-06-15T08:00:02+00:00","dateModified":"2019-03-12T09:31:40+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/"},"wordCount":1185,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["nio"],"articleSection":["nio"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/","name":"Java Nio ByteBuffer Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2017-06-15T08:00:02+00:00","dateModified":"2019-03-12T09:31:40+00:00","description":"This article is a tutorial on demonstrating the usage of the Java Nio ByteBuffer. All examples are done in the form of unit tests to easily prove the","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/nio\/java-nio-bytebuffer-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-bytebuffer-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 ByteBuffer 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\/af856abe55325eb35866dc62a821c1bc","name":"JJ","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9c7eb5a98aedd6421eb285eea1b5e8991789024a35e415108b292edb81a37c3f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9c7eb5a98aedd6421eb285eea1b5e8991789024a35e415108b292edb81a37c3f?s=96&d=mm&r=g","caption":"JJ"},"description":"Jean-Jay Vester graduated from the Cape Peninsula University of Technology, Cape Town, in 2001 and has spent most of his career developing Java backend systems for small to large sized companies both sides of the equator. He has an abundance of experience and knowledge in many varied Java frameworks and has also acquired some systems knowledge along the way. Recently he has started developing his JavaScript skill set specifically targeting Angularjs and also bridged that skill to the backend with Nodejs.","sameAs":["http:\/\/examples.javacodegeeks.com\/","https:\/\/za.linkedin.com\/in\/jean-jay-vester-b135906","https:\/\/x.com\/jeanjayvester1"],"url":"https:\/\/examples.javacodegeeks.com\/author\/jean-vester\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/47434","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\/129"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=47434"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/47434\/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=47434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=47434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=47434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}