data is used, so the code is repeated.
In this case, you need to divide classes more rationally.The most likely input data is integers, decimals, dates, and strings. Therefore, it is best to design a special input data type to complete the input data function, in addition, the input data can be verified.The following describes the classes used to process input data, but only integers and strings can be obtained.
Import Java.
not be omitted, mainly because it is necessary to develop good coding habits as a newbie.2. This Article is compiled in linux, which is similar to File. pathSeparator and File. separator. This representation is for cross-platform and robust considerations.3. Some operations in the Code have multiple execution methods. I have adopted the method 1... method 2... expression, which can be compiled with just a few simple annotations.4. the Code does not throw exceptions on the main method, but captu
develop good coding habits as a newbie.2. This Article is compiled in linux, which is similar to File. pathSeparator and File. separator. This representation is for cross-platform and robust considerations.3. Some operations in the Code have multiple execution methods. I have adopted the method 1... method 2... expression, which can be compiled with just a few simple annotations.4. the Code does not throw exceptions on the main method, but captures them separately, causing code to be too long.
:
The server's connection to the client is equivalent to 1:1, so if the number of connections goes up, the pressure on the servers will be great.
If the main thread acceptor blocked, then the entire server will be blocked, a single point of serious
When the number of threads expands, the performance of the entire server drops
The improvements can be based on the thread pool or Message Queuing , but there are some problems:
The number of thread pools, the number of
Reprint Please specify source: http://www.cnblogs.com/Joanna-Yan/p/7723174.htmlPrevious: Java IO programming Full Solution (ii)--traditional bio programmingIn order to solve the problem that the synchronous blocking I/O faces a link that requires a threading process, someone later optimizes its threading model, and the backend uses a thread pool to handle requests from multiple clients, forming the number o
ioexception
Normal
Create a new file
Public Boolean exists ()
Normal
Determine whether a file exists
Public Boolean Delete ()
Normal
Delete an object
Public Boolean isdirectory ()
Normal
Determines whether the specified path is a directory.
Public long length ()
Normal
Size of the returned File
Public String [] list ()
Normal
Lists all the contents of a specified directo
Goal:1, master the three kinds of system support for IO:System.outSystem.inSystem.err2, master the difference between System.out and System.err.3, master input, output redirect.Constants of the System classJava has some support for the system class for IO, and three constants are prefabricated.PrintStream Out,printstream Err,inputstream in.Variables declared with static final are global constants, and all word letters must be capitalized if they are c
/writers)
Read and write basic type data (long, int etc.)
Read and Write objects
Let's take a look at the two graphs to get a general picture of the inheritance of these classes and their effects.Figure 1:java Integration Relationship of IO classFigure 2:java The media responsible for each class in IOIii. basic usage of
NIO and IO in the java file system, and nioio in the java File System
Java introduced the java NIO mechanism since jdk1.4:
The notable features of NIO are channel, buffer, selector ), non-blocking calls not provided in traditional I/O mechanisms are added to the NIO mechanis
(bw! = Null) {try {bw. close ();} catch (IOException e) {// TODO Auto-generated catch blockthrow new RuntimeException ("Write close failed ");}}}}}4. Custom Character Buffer
/* After understanding the principle of the special method readLine in the BufferedReader class, you can customize a class that contains a method with the same function as readLine. Simulate BufferedReader */import java.
solve this problem well and provide methods such as print ().
In addition, printwriter and printstream are directly created if no file object exists.
They will overwrite the original files, but there is no way to add them.
It's easy to solve this problem. Check the API documentation again.
Printwriter has a constructor.Printwriter (writer out), that is, the ability to pass in writer objects
Printstream has a constructor.Printstream (outputstream out), that is, an outputstream object c
the avaliablebytes () of the stream () function to check the number of bytes in the current stream that can be read, so that it will not be blocked.
Java code
Import java. Io. ioexception;
Import java. Io. inputstream;
Io (input and output) operations in java (IV), iooutputThe main operations of java io have been completed.This section describes other content about java io.Serializable serialization Instance 1: Object serialization Copy codeThe Code is as follows:Import
//***
* Java IO detailed description see http://www.senma.org/blogs/356.html
* You can also refer to: http://www.cnblogs.com/rollenholt/archive/2011/09/11/2173787.html
*/
Import java. io. BufferedReader;Import java. io. File;Impor
[Java iO] _ file class notes
Objectives of this chapter:
Measure the test taker's knowledge about the functions of the file class.You can use methods in the file class to operate files.
File class
In the entire Io package, the only class that indicates the file is the file class. You can use the File class to create and delete files. To use the File class, first
automatically create a path that does not exist. If the path does not exist, the file does not exist, and cannot be created, but the file does not exist but cannot be opened, a FileNotFoundException exception will be thrown. FileOutputStream (String name, boolean append) throws FileNotFoundExceptionFileOutputStream (File file, boolean append) throws FileNotFoundExceptionFileInputStream and FileOutputStream support all read/write methods provided by InputStream and OutputStream. Note: when insta
{...Private void flushbuffer () throws ioexception {If (count> 0 ){Out. Write (BUF, 0, count );Count = 0;}}Public synchronized void write (int B) throws ioexception {If (count> = Buf. Length ){Flushbuffer ();}Buf [count ++] = (byte) B;}...}
This class provides a caching mechanism to write data into the output stream when the cache capacity reaches a certain number of bytes. First, it inherits filteroutpu
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.