Streaming and decorator construction in java i/o, JAVA Programming

Assignment Help:

Java output and input is described in terms of an abstract concept named a "stream", which is a sequence of data.

There are 2 types of streams.

1.      Byte streams (8 bit bytes)  Abstract classes are: OutputStream and InputStream

2. Character streams (16 bit UNICODE) Abstract classes are: Writer and Reader

 java.io.* classes need the decorator design pattern. The decorator design pattern added responsibilities to objects at runtime. Decorators are more reliable than inheritance because the inheritance added responsibility to classes at compile time. The java.io.* classes access the decorator pattern to construct different combinations of behavior at runtime based on some basic classes.

 

 The new I/O (NIO) offers better performance and better scalability?

 

Java has long been not suited for deploying programs that perform a lot of I/O functions. Furthermore, commonly needed tasks such as non-blocking, file locking and asynchronous I/O operations and ability to map file to memory were not require. Non-blocking I/O operations were found through work around such as multithreading or using JNI. The New I/O API in J2SE 1.4 has modified this situation.

A server's ability to handle several client requests effectively depends on how it performs I/O streams. When a server has to communicate hundreds of clients simultaneously, it has to be able to use I/O services frequently. One way to cater for this scenario in Java is to use threads but having almost one-to-one ratio of threads (100 clients will have 100 threads) is prone to enormous thread overhead and may give in scalability and performance problems due to consumption of memory stacks and CPU context switching. To overcome this situation, a new set of non-blocking I/O classes have been produced to the Java platform in java.nio package.

The non-blocking I/O mechanism is making around Channels and Selectors. Channels, Selectors and Buffers are the core of the NIO.

 

 

885_Untitled.png

 

A Channel class presents a bi-directional communication channel in between datasources such as a file, a socket, or an application component, which is capable of producing one or more I/O operations such as writing or reading. Channels may be non-blocking, which means, no I/O operation can wait for data to be written or read to the network. The nice thing about NIO channels is that they may be closed and asynchronously interrupted. So if a thread is blocked in an I/O operation on a channel, another thread may interrupt that blocked thread.

 


Related Discussions:- Streaming and decorator construction in java i/o

Android app implemented on a website, iPhone /Android app implemented on a ...

iPhone /Android app implemented on a website Project Description: I need someone to implement an iPhone/Android app onto a website page, So users can be able to use the Ap

Develop a simple polling web application , Develop a simple polling (voting...

Develop a simple polling (voting) web application according to the following specifications: 1. Initially a page should be presented to the user where he can enter his/her

Define class diagram , Class diagram technique is vital within Object Orie...

Class diagram technique is vital within Object Oriented functions. Class diagrams illustrate the kinds of objects in the system and the several static relationships among them. Cl

Questions pseudocodes, 1. Write the pseudocode to get the input of 10 integ...

1. Write the pseudocode to get the input of 10 integers from the user and add them up and output the total. (4 points) 2. Compute the output of following pseudocode. Assume that

How jms is different from rpc, In RPC the method invoker waits for the meth...

In RPC the method invoker waits for the method to finish implementation and return the control back to the invoker. Therefore it is completely synchronous in nature. Whereas in JMS

What is jdbc abstraction and dao module, Using this module we can keep up t...

Using this module we can keep up the database code clean and easy, and prevent problems that result from a failure to close database resources. A new layer of meaningful exceptions

Implement relationship using a java program, Implement relationship using a...

Implement relationship using a java program. Assume each course has a course title, code, subject and number of credits while each student has a name, registration number, list of

Data access objects (DOA) in JDBC, Business Objects represent the data cl...

Business Objects represent the data client. They are the objects that need access to the datasource to obtain and store data. Data Access Objects abstract the relying data access i

What is spring, Spring is an open source framework created to address the d...

Spring is an open source framework created to address the difficulty of enterprise application development. One of the chief benefits of the Spring framework is its layered archite

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd