1. Study summary 1.1 This week summarize multiple streams and file-related content in the way you like (mind map or other).
2. System-oriented integrated design-Library management system or shopping cart use flow and documentation to transform your library management system or shopping cart. 2.1 A brief description of how to use streams and files to transform your system. What is the format of the data in 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? 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 requires that the weekly code statistics be fused into a single table.
| Week Time |
Total code Amount |
New Code Volume |
total number of files |
number of new files |
2
| 0 |
0 |
0 |
0 |
| 3 |
235 |
235 |
6 |
6 |
| 5 |
498 |
263 |
|
7 |
| 6 |
711 |
213 |
+ |
6 |
| 7 |
1237 |
526 |
|
one |
| 8 |
1670 |
433 |
|
9 |
|
2352 |
682 |
|
5 |
| ten |
2940 |
|
|
< td>
|
class= "odd" >
| all |
3451 |
511 |
|
|
| " |
3906 |
455 |
|
[ | ] body>
Option: 4. Flow and Document Learning Guide (the job content is all selected at the bottom) 1. Character stream and text file: Using PrintWriter (Write), BufferedReader (read) writes student object (attribute: Int ID, String name,int age,double grade) to the file Student.data, Read from the file display. 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)
For:
1.2 What is the size of the generated file (using the right-click File Properties view)? Analyze the file size
For:
1. Build file Size: 48 bytes.
2.int (1 bytes), String (4 bytes), double (4 bytes), delimiter (3 bytes), line break (3 bytes)
----->1+4+2+4+3+2=16
----->16*3=48
1.3 If the println method of PrintWriter is called, but not close at the back. What is the file size? Why?
A: The file size is 0 because we know that calling PrintWriter just writes the data to the buffer, and if there is no close, the data is lost!
Reference: Topic specific requirements see flow and document Experimental task book-title 1-2.1 Reference code: TEXTFILETEST.JAVA2. Buffer Stream 2.1 Use PrintWriter to write 10 million lines to a file (whatever it is), and then compare the speed (read, not output) of using BufferedReader with scanner to read data from the file, 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
Answer: Use BufferedReader fast. The difference between the two mechanisms: the use of the BufferedReader buffer, the time to read the data directly from the buffer operation on the line, and Scanner each time from the file operation, it is naturally more slow.
2.2 Replace the PrintWriter with BufferedWriter to see if the speed of writing to the file has improved. Record the elapsed time of both. Try to analyze the reason.
A: There will be ascension, it should be related to its buffer zone.
Reference: Subject specific requirements see flow and Document Experiment Task Book-topic 1-2.2 to 2.3 Reference code: BUFFEREDREADERTEST.JAVA3. Character encoding 3.1 an existing EncodeTest.txt file that contains some Chinese, the file uses UTF-8 encoding. 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)
Answer: Garbled characters will occur. The FileReader character set that is taken is decoded by the system's default character set (GBK), but the text file is encoded using "UTF-8", and therefore garbled.
201621123013 Java programming 12th Week of study summary