Hello guys, if you are preparing for Java developer interview then you may know that Networking and Socket Programming is one of the important areas of Java programming language, especially for those programmers, who are working in client server-based applications. Knowledge of important protocols like TCP and UDP in detail is very important, especially if you are in the business of writing high-frequency trading applications, which communicate via FIX Protocol or native exchange protocol. In this article, we will some of the frequently asked questions on networking and socket programming, mostly based around TCP IP protocol.
Friday, May 5, 2023
Saturday, April 22, 2023
ByteBuffer Read Write Example in Java
Hello guys, if you have worked with Java NIO API then there is a good chance that you may be familiar with ByteBuffer, one of the important class which is used to read and write data from channels. Java NIO Buffers are used when interacting with NIO Channels like FileChannel. As you know, data is read from channels into buffers, and written from buffers into channels. A buffer is essentially a block of memory into which you can write data, which you can then later read again. This memory block is wrapped in an NIO Buffer object, which provides a set of methods that makes it easier to work with the memory block. If you compare this with traditional java.io package then you will remember that we read and write data from stream into array but in case of NIO, we read and write data from channels into ByteBuffer.
Labels:
ByteBuffer
,
Java NIO Tutorial
Monday, May 23, 2022
Difference between Direct, Non Direct and Mapped ByteBuffer in Java?
ByteBuffer is one of the important classes of Java NIO API. It was introduced in java.nio package on JDK 1.4, it not only allows you to operate on heap byte arrays but also with direct memory, which resides outside the JVM. There are mainly three types of ByteBuffer in Java - Direct Byte Buffer, Non-Direct ByteBuffer, and mapped byte buffers. You can create both direct and non-direct buffers using java.nio.ByteBuffer class, while MappedByteBuffer is a subclass of ByteBuffer, which is created by FileChannel.map() method, to operate on memory-mapped file.
Labels:
java IO tutorial
,
Java NIO Tutorial
Subscribe to:
Posts
(
Atom
)