IO Flow Basic ConceptsIO streams are used to process data transfer between devicesJava's manipulation of data is done in a streaming wayThe objects that Java uses to manipulate streams are on IO packetsStreams are divided into two types by operational data: byte stream and character streamFlows are divided into: input stream, output stream.
Abstract base class f
The main thing about Java IO is the input and output of the file, so I study the systemThere are several key classes of the main File fileinputstream fileoutputstream inputstreamreader outputstreamwriter bufferedreader BufferedWri ter Bufferedinputstream BufferedoutputstreamBelow I sit down the detailed introduction:The file class is the most basic class of filesYou can get the basic properties of a file.Im
.
Concretedecorator: decorator
A specific decoration object adds specific responsibilities to the specific decoration objects held internally
Decorator mode in outputstream in Java. Io package:
In the java. Io package, outputstream is a decorator mode design. The outputstream abstract class is used as the decorator, an
source and purpose.Source: input stream. InputStream ReaderPurpose: The output stream. OutputStream Writer2. Whether the manipulated data is plain text.Yes: Character streamNo: Byte stream3. When the system is clear, then specify which specific object to use. To differentiate by device:SOURCE device: Memory, hard disk, keyboardPurpose device: Memory, HDD, consoleHere's a simple practice code:public class Inputstreamreaderdemo {public static void Main (string[] args) throws
fullFwriter.Close();//Close FileWriter object //Read fileFileReader Freader =NewFileReader (file);Char[] CS2 =New Char[ the]; Freader.Read(CS2);//This is not read by the while loop because it knows the length is not greater than 15 for(CharC:CS2) {//Traversal outputSystem. out.Print(c); } freader.Close();Operation Result:i love javaReference1. Java Stream (stream), file, and Io | Beginner's Tuto
the concept and function of flow
Learning Java IO, you have to mention the Javaio stream.
A stream is a sequence of byte sets with a starting point and an end point, which is the general term or abstraction of the data transfer. That is, the data transfer between the two devices is called flow, the essence of the stream is data transmission, according to the data transmission characteristics of the flow in
] {
System.out.println (line);
line = Br.readline ();
}
Br.close ();
}
catch (IOException e) {
System.out.println ("IO Problem");}}
This program contains a try...catch...finally exception handler. Exception handling can be referenced in the Java Advanced Tutorial
Adorners and functional combinations
The key to program
.
5
public int available () throws ioexception{}Returns the number of bytes that the next method invoked on this input stream can be read from this input stream without blocking. Returns an integer value.
In addition to InputStream, there are some other input streams, more details refer to the following links:
Bytearrayinputstream
DataInputStream
FileOutputStreamThis class is used to create a file and w
flush difference: After flush refreshes, the stream can continue to be used, and when close is refreshed, the stream is closed. Fw.close (); }}Attention:In fact, Java itself can not write data, but to call the system internal way to complete the writing of data, using system resources, it is important to close the resources.Close () and flush () differences:Flush () After flushing, the stream can continue to be used;When close () is refreshed, the st
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
Class-level diagram that describes the input stream and the output Stream.The two important streams that will be discussed below are FileInputStream and fileoutputstream:
FileInputStreamThe stream is used to read data from a file, and its objects can be created with the keyword NEW.There are several construction methods that you can use to create Objects.You can use the file name of a string type to create an input stream object to read the File:New FileInputStream ("c:/
Because the project needs to use Java to develop a background server program, C + + programmers will learn java. Blog content is used to record my learning process. Several network IO models under Unix/linux have been mentioned in previous blogs, but most of them are system calls under Unix/linux.Most of the blog content from the network information and books "Ne
{Selector acceptselector = Selectorprovider.provider (). Openselector (); /*Register the selector on the server socket and set the notification to accept the acceptance method. this tells selector that the socket wants to be placed in the ready table when the Accept operation occurson, therefore, agree that multivariate non-clogging I/O occurs. */Selectionkey Acceptkey = Ssc.register (Acceptselector,Selectionkey.op_accept);int keysadded = 0;The/*select method returns when an operation that has b
ioexception{Selector acceptselector = Selectorprovider.provider (). Openselector (); /*Register the selector on the server socket and set the notification to accept the acceptance method. this tells selector that the socket wants to be placed in the ready table when the Accept operation occurson, therefore, agree that multivariate non-clogging I/O occurs. */Selectionkey Acceptkey = Ssc.register (Acceptselector,Selectionkey.op_accept);int keysadded =
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.