I. Io and stream
Data input and output (I/O for input/output)The input and output of standard input devices and standard output devices are referred to as standard I/OThe input and output of files stored on an external disk are referred to as files
So far, the input and output we have discussed is the object of the system-specified standard device (the input device is the keyboard and the output device is the monitor). In real-world applications, disk files are often used as objects. The data
10th. Input/output streamThe I/O (input/output) Stream class library provides data interaction services between objects.The Stream Class library pre-defines a batch of stream objects to connect to common external devices.Programmers can define the
A file stream is a stream of data that is an input and output object as an external memory file. The output file stream is the data that flows from memory to the external memory file, and the input file stream is the data that flows from the
1. Stream Class Library(1), there is no input and output in C + +, the standard library contains an I/O Stream class library.printf and scanf are called functions in the C language; output to screenCout and Cin in C + + are called objects; input is
To make a class A stream class, you first define two member functions Savetostream and Loadfromstream for the class, (how to define see "Simplified handling of stream Class I/O") and then consider the version of the stream in both functions.
Have a nice smileAsk questionsHow does a Java lambda expression and stream work???solve the problemThe syntax of a lambda expressionBasic syntax:(parameters) -> expression或(parameters) ->{ statements; }Read the example study!Example one: Define a
Stream is a tool that uses functional programming to perform complex operations on a collection class.1.collect (ToList ())Generate a list from the values in the StreamList collected = Stream.of ("A", "B", "C")
First the stream stream classHeader file # include Its function is the conversion between different types, and the C language fscanf and fprintf role is the same, but more than the C language more convenient and better use.Very easy to use
1. file stream
Ofstream, derived from ostream, used to write filesIfstream, derived from istream, used to read filesFstream, derived from iostream, is used to read and write files.
Ii. Open a file
After the stream object is described, you can use
PackageCn.jbit.inputstream;ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException; Public classTest {/** * @paramargs*/ Public Static voidMain (string[]
1. Basic exercises (1) Textbook Exercise 11-7 (2) Textbook Exercise 11-3 (3) Textbook Exercise 11-42. The application exercise (1) is known to have class list file List.txt (see Experiment 7 Accessory Pack). Write an application implementation
Import java.io.*;
Import java.util.*;
Use the random file stream class Randomaccessfile to read a text file upside down.
public class Home {
public static final void main (string[] args) {
try {
File F = new file ("Exp.txt");
if (!f.exists ())
Reader and Writer are the abstract base classes of all the character stream classes. They are used to simplify the input and output programming of strings, that is, to read and write text data.
Instance:
[Java]Import java. io .*;Www.2cto.comPublic
The lambda expression is described earlier, but we can see that the lambda expression actually simplifies the writing of a part of the code and is not a very useful language feature. But if the lambda expression fits into the Stream class library
"Single duty" mode
In the design of software components, if the division of responsibility is unclear, the result of using inheritance is often changed with the demand, the subclass expands rapidly, and the repetition code is full, the key
Chapter 6,
EPUB
File Processing
--
Analysis
Container
File and
. OPF
File
In this chapter, we will continue with openbookinternal of the fbreaderapp class introduced at the end of chapter 3, and begin to introduce parsing the container file and.
I. file read/write
As mentioned above, stream reads and writes mainly include , get, put, read, write, and other operations. ofstream inherits from ostream, and ifstream inherits from istream, therefore, the operation functions are consistent.
C ++
1. java implements data input and output through the concept of stream, or reading and writing is easier to understand. The following four classes are the base classes of all streams, which process the reading and writing of bytes and characters
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.