[Non-original] Some good articles about Java NI/O ~~~, Ni haowen

Source: Internet
Author: User

[Non-original] Some good articles about Java NI/O ~~~, Ni haowen

With regard to Java NIO, I have heard of such a thing before, understand the implementation principles, and have no chance to actually use it in projects.

However, some netizens recently discussed this issue in the group, so they came out to baidu and found such a sharing post.

The main content in the post is about TCP or pipe exceptions in the Selector mechanism of Java NIO,

And the solution. Thank you for sharing the details here.

 

Http://blog.csdn.net/haoel/article/details/2224055

 

There are some things about NIO, such as the Mina framework and netty framework of apache,

If you have time, you can solve it.

Analysis of Mina and Netty

Http://ifeve.com/netty-mina-in-depth-1/


A 10000-character English article on java, which we will use

Example of Applet.

The source program is as follows:

Import java. awt. Graphics; // declare that the applet uses the Graphics class in the java. awt package

Import java. applet. Applet; // declare that the applet uses the applet Class in the java. Applet package

Public class. MyApplet extends Applet {// declare a public class named MyApplet, which inherits the Applet class

Public String s; // declare a String

Public void init () {// Applet Initialization Method

S = new String ("Hello World! "); // Create a string

}

Public void paint (Graphics g ){

G. drawString (s, 60, 40 );

}

}

I. Explanation:

1. Graphics class allows the Applet to draw straight lines, rectangles, ovles, and strings. In this program, "Hello World!" is drawn !" String

2. Method init () to create a string

3. in paint (), g is the Graphics class object. It calls the drawString method of Graphics to draw a string.

4. The first parameter in the drawString method is the string s to be drawn. The following two parameters (60, 40) indicate the plane coordinates in the lower left corner of the string, 60 is the horizontal coordinate, and 40 is the vertical coordinate.

5. The origin of the Java coordinate system is in the upper left corner, and the vertical axis points to the bottom. The coordinate unit is pixel.

2. Compile the source program as a Class file

Javac MyApplet. java

3. the Applet does not have the main () method as the entry to the Java interpreter. Therefore, you must write an HTML file, embed the Applet into the HTML file, and then run it using appletviewer, alternatively, you can run HTML files in a Java-supported browser. The HTML file content is as follows:

<Html>

<Head>

<Title> My Applet </title>

</Head>

<Body>

<Applet code = MyApplet. class width = 400 height = 100> </applet>

</Body>

</Html>

Java provides all he luxuries of object-oriented programming: class

Hierarchy, inheritance, encapsulation, and polymorphism -- in a context that is truly useful and

Efficient.

The main reason for developing object-oriented software, besides clarity and simplicity, is

The desperate hope that somehow the objects you develop will be reused. Java not only

Encourages software reused. Java not only encourages software re ...... the remaining full text>

Write a piece of code in java to get the words in the following article (the length is between 5 and 15, and c is before o) and display them.

Put that article in the file, read it using the IO stream, or directly use String s = the above section, and then StringTokenizer st = new StringTokenizer (s, ""); String temp; while (st. hasNext () {temp = st. next (); if (temp. length ()> = 5 & temp. length () <= 15) {for (int I = 0; I <temp. length ()-1; I ++) {if (temp. toChar (I) = 'C') if (temp. toChar (I + 1) = 'O') System. out. println (temp) ;}the general idea is this .}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.