Serialization, deserialization, and IO serialization of Java-io stream objects
Basic serialization operations
1. Object serialization means to convert an Object into a byte sequence, and vice versa.
2. The ObjectOutputStream and writeObject methods are used to write objects to the output stream;
The deserialization stream (ObjectInputStream). The readObject me
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
. According to the function of the Division: node flow and packaging flow.four basic streams : Byte input stream, byte output stream, character output stream, character input stream
BYTE stream
Character Stream
Output stream
OutputStream
Writer
Input stream
InputStream
Reader
The four basic streams are abstract classes : The other flows are inherited from the four main classes.We cannot create four base stre
IO has been one of the core parts of software development, and with the improvement of Internet technology, IO is becoming more and more important. Throughout the development community, the ability to skillfully use IO is important not only for companies but also for developers. Java's IO mechanism is constantly being
Channels are used in concert with the buffer in NIO. A channel is a bidirectional channel that is readable and writable. It is a bit similar to stream, but stream is unidirectional, the application does not directly perform read/write operations on the channel, but must use the buffer. For example, when reading a channel, you must first read the data into the corresponding buffer and then read it in the buffer.
An example of using filechannel
Package NiO; import
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
1. Get line number function case for custom class simulation LineNumberReader2. Code implementation:(1)Mybufferedreader. Java:1 Packagecn.itcast_08;2 3 Importjava.io.IOException;4 ImportJava.io.Reader;5 6 /*7 * Simulate BufferedReader's readline () function with reader8 * 9 * ReadLine (): reads one line at a time, determines whether to end with newline characters, returns only content, and does not return newline charactersTen */ One Public classM
Today, when using AB for stress testing, it is unintentional to discover:Requests per second:xxx [#/sec] (mean)Ab-n 5000-c http://www:8080/upload/5kb.jpg (nioserver:700 aio:400)Ab-n 5000-c http://www:8080/upload/18kb.jpg (nioserver:560 aio:360)Ab-n 2000-c http://www:8080/upload/134kb.jpg (nioserver:330 aio:300)Ab-n 2000-c http://www:8080/upload/134kb.jpg (nioserver:330 aio:260)ab-n 3000-c http://www:8080/upload/134kb.jpg (nioserver:300 aio:310)Ab-n 5000-c http://www:8080/upload/134kb.jpg (nioser
performance of the program. Xiao Ming himself to pick up the book no matter waiting for the book sooner or later, expect to find a small just sent to, in case the small just forget or have urgent busy other, that book is gone.DiscussThere are really a lot of similarities between synchronous and asynchronous, blocking, and non-blocking, and it's easy to confuse. Wikis also equate asynchronous with non-blocking, and more people think they are different. There may be many reasons, each person's kn
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.
/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
folder B: Renaming considerations if the path name is the same, it is renamed. If the path name is different, it is renamed and clipped. C: Delete Note: Delete in Java does not go to the Recycle Bin. To delete a folder, note that the folder cannot contain files or Folders file class (the function of the file Class) A: Judge function public boolean isdirectory (): Determines whether the directory public boolean ISFI Le (): Determine if the file is
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;
//***
* 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
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.