Java-Finding Remaining Data

Finding Remaining Data The boolean method hasRemaining( ) will tell you if you’ve reached the buffer’s limit when reading. The following is a way to read elements from a buffer : Alternatively, the remaining( ) method will tell you the number of elements that remain from the current position to the limit. You can use a … Read more…

Java-NIO

NIO Beginning with version 1.4, Java has provided a second Input/Output system called NIO (which is short for New Input/Output). It supports a buffer-oriented, channel based approach to Input/Output operations. With the release of JDK 7, the NIO system was greatly expanded, providing enhanced support for file handling and file system features. In fact, so … Read more…

PipedOutputStream and PipedInputStream

Java-PipedOutputStream and PipedInputStream

PipedOutputStream and PipedInputStream The PipedOutputStream class and PipedInputStream class provide functionality for threads to communicate and exchange data between them. The PipedOutputStream class lets a sending thread write a stream of bytes to an instance of the PipedInputStream class, which a receiving thread uses to subsequently read those bytes, as shown in following figure : PipedOutputStream declares a … Read more…

Java-PipedWriter and PipedReader

PipedWriter and PipedReader The PipedWriter class and PipedReader class provide functionality for threads to communicate and exchange data between them. The PipedWriter class lets a sending thread write a stream of characters to an instance of the PipedReader class, which a receiving thread uses to subsequently read those characters, as shown in following figure : PipedWriter declares a void connect(PipedReader … Read more…

Java-OutputStreamWriter and InputStreamReader

Java-OutputStreamWriter and InputStreamReader

OutputStreamWriter An OutputStreamWriter is a bridge from character streams to byte streams: Characters written to it are encoded into bytes using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform’s default charset may be accepted. Each invocation of a write() method causes the … Read more…