First, the concept
NiO is the new IO, the library is introduced in JDK1.4. NiO and IO have the same effect and purpose, but the implementation is different, NIO is mainly used in blocks, so the efficiency of NIO is much higher than IO. Two sets of NIO are provided in the Java API, one for standard input output NIO and
[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
When learning Java NIO and IO APIs, a problem quickly emerges in the brain:When to use IO? When to use NiO?The author of this article will try to clarify some of the differences between Java NiO and Io, their use cases, and how they each affect our code design. The main diff
from the keyboard from the user String str = input . ReadLine (); Send the user input to the server out.println (str); Get string echo = Buf.readline () received to the service-side callback System.out.println (Echo);} }Considering that the full Java sample code is too large to affect reading, so here is not a full post, if need to download directly on GitHub, here is.As you can see, server needs to open a thread for each client
Java IO Stream is the basis for the implementation of input/output, it can easily implement data input \ Output operation, in Java, the different input \ Output source abstraction as "flow", through the way of the stream allows the Java program to use the same way to access different input/output sources. Stream is an
bytes and byte arrays.So the character stream is made up of characters that the Java Virtual machine converts bytes into 2-byte Unicode characters.3. Byte stream can be used for any type of object, including binary objects, while character streams only handle characters or strings, byte stream provides the ability to handle any type of IO operation, but it cannot directly handle Unicode characters, and the
1. Object serialization is to save the current state of the object.
2.There are two main ways to save the object status:
1)Object serialization (write the object to a file and deserialize it later, as shown in the following example)
If the stored data is used in JavaProgramObject serialization is used for internal interaction;
2)Write a file (write an object to a text file. Note thatText Files)
If the stored data is used to interact with other non-
Java IO is a set of APIs that Java uses to read and write data (input and output). Most programs process some input and produce some output from the input. Java provides the java.io package for this purpose.Code GitHub Address: Https://github.com/loveincode/StudyTest/tree/master/src/IORange of java.io PackagesThe java.
1.Java IO Flow concept, classification, class diagram.
The concept of 1.1 Java IO stream
Java IO is the basis of input and output, can easily realize the data input and output operation. In
FileFile can create new, delete, rename files and directories, but cannot view file contents.Construction methodpublic File(string pathName);//以path路径创建对象publicFile(StringString child);//以parent为父路径,child为子路径创建File对象Unix under Path delimiter is '/', Windows is ' \ ' or '/'A program that understands the file class//create path plus file in D driveFile d1= New File ("D:/dir1");//Create D1 path if(!d1.exists()) {D1.mkdir ();//If the D1 path does not exist, create the path} file D2 = new
BufferedReader (rdfile); Creates a BufferedReader object String strLine; while NULL ) { System.out.println (strLine);} Brdfile.close (); Example, rdfile this FileReader object wrapped in BufferedReader object brdfile, directly manipulate the Brdfile object, you can implement the buffering function of the read operation.Similarly, read by byte can use the Bufferedinputstream class to wrap the Inputsteam.4. I/O architectureNow that we've learned about
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
when should I use IO , when to use NIO it? In this article, I'll try to clearly parse the differences between Java NIO and IO , their usage scenarios. And how they affect your code design. Java NIO and the IO The main differenceThe following table summarizes
Io (input and output) operations in java (3), iooutputTo be honest, I don't really like the Java language. Although it is very powerful, there are many ready-made APIs that can be called.But I always feel that it makes simple things too complicated and sometimes gets lost.I cannot tell whether it is for writing or for the language itself.The first programming lan
Java learning notes 43 (brief introduction to the print stream and IO stream tools) and learning notes
Print stream:
There are two classes: PrintStream and PrintWriter. The methods of the two classes are the same. The difference is that the constructor
PrintStream: constructor: receives the File type, receives the string File name, and receives the byte output stream (OutputStream)
PringWriter: constructor:
transmitting data4 classes are abstract classes can not be instantiated, need to pass 4 abstract classes provided by the method to implementV. InputStream Architecture 5.1, byte input stream base classFileInputStream: Reading data from a fileStringBufferInputStream: Rotate the string into the input stream, this class is obsolete and replaced by StringbufferreaderPipedInputStream: Connecting a PipedOutputStream It is a pipeline to the inflowBytearrayinputstream: The byte array is rotated as an i
Reprint Please specify the Source: Jiq ' s technical BlogIntroductionNIO, or new IO, was introduced in JDK1.4 to improve IO speed. It is important to note that Javanio is not completely non-blocking IO (no-blocking io) because some of these channels (such as FileChannel) can only be run in blocking mode, while other ch
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.