As the earlier blog gives you a basic knowledge about java NIO. Here, is the some examples to understand the concept of channels and buffers. Channel is a foundational construction. It helps you to connect the input, output, hardware devices, files and sockets. Buffer: it is a storage place where we can store the temporary data. Let us create a channel for processing file reading and writing operations. Make it connected with a buffer. File Reading Example using java NIO: · It includes the built in packages. · A public class is created with main() function. · Three objects are created. FileInputStream,FileChannel and ByteBuffer. · Data is read through the channel and gets stored in buffer. · Until the buffer has data, it reads the data and display it in the output screen · ...
Comments
Post a Comment