1. Summary of this week's study
2. System-oriented integrated design-Library management system or Shopping cart 2.1 describes how to use streams and files to transform your system. What is the format of the data in the file?
- To write bibliographic information to a file, to read the library bibliographic information, to achieve the reading of the file
2.2 Brief description of what interfaces and classes are used in the file reading and writing section of the system with the stream associated with the file? Why use these interfaces with classes
File class: To access the filesystem on disk, you need to use the
Writer class: The BufferedWriter class has a large buffer memory, the output is fast
2.3 Read and write file-related code. Critical lines need to be annotated.
3. Code volume Statistics 3.1 Statistics the amount of code completed this week
Weekly total |
code volume |
|
New Code volume |
|
Total number |
| of
new files |
|
|
First week |
|
189 |
|
189 |
|
10 |
|
10 |
|
Second week |
|
304 |
|
304 |
|
9 |
|
9 |
|
Third week |
|
557 |
|
557 |
|
10 |
|
10 |
|
Week Four |
|
621 |
|
621 |
|
8 |
|
8 |
|
Week Five |
|
326 |
|
326 |
|
7 |
|
7 |
|
Week Six |
|
972 |
|
972 |
|
12 |
|
12 |
|
Seventh Week |
|
338 |
|
338 |
|
4 |
|
4 |
|
Eighth Week |
|
379 |
|
379 |
|
6 |
|
6 |
|
Nineth Week |
|
492 |
|
492 |
|
5 |
|
5 |
|
Tenth Week |
|
473 |
|
473 |
|
6 |
|
6 |
|
11th Week |
|
527 |
|
527 |
|
10 |
|
10 |
|
12th Week |
|
661 |
|
661 |
|
7 |
|
7 |
|
4. Stream and Document learning Guide 4.1 characters stream with text file: Use PrintWriter (write), BufferedReader (Read)
Writes the Student object (property: Int id, String name,int age,double grade) to the file Student.data, read from the file display.
4.1.1 generated three student objects, using PrintWriter's Println method to write Student.txt, one student per line, and each student's attribute separated by |. Use scanner or BufferedReader to read the Student.txt data. (Key code, occurrence number)
4.1.2 How much is the generated file size (using right-click File properties)? Analyze the file size
4.1.3 If the println method of PrintWriter is called, but not close at the back. What is the file size? Why?
- The file size is 0 bytes because the close () method is not called and the related data is still in the buffer
4.2 Buffered Stream 4.2.1 use PrintWriter to write 10 million lines to a file (whatever it is), and then compare the speed (read only, not output) of using BufferedReader with the data read from the file using scanner, which method is used fast? Intercept the test source code, the number of the study. Please analyze the reasons in detail. Tip: You can use JUNIT4 to compare run times
- BufferedReader reading data faster than scanner
- BufferedReader has greater buffer memory; Scanner requires parsing of input data, which is more time consuming
4.3 character encoding 4.3.1 an existing EncodeTest.txt file that contains some Chinese, the file is encoded using UTF-8. Use FileReader and BufferedReader to read the EncodeTest.txt text into and out. Do you have garbled characters? Why does it have garbled characters? How to solve? (Key code, occurrence number)
201621123040 Java programming 12th Week of study summary