201621123034 Java programming 12th Week of study summary

Source: Internet
Author: User

Job 12-Stream with file 1. This week's study summary 1.1 summarizes multi-stream and file-related content in the way you like (mind mapping or other).

2. System-oriented integrated design-Library management system or shopping cart

Use streams and files 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?

A: Books and User both are objects, so use the object stream to write to the ObjectOutputStream file separately, and write a method to save the modified file. The file format written with the object stream is hexadecimal.

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?

A: Interfaces InputStream , OutputStream their ObjectInputStream and ObjectOutputStream subclasses, and file classes are used File . In order to ensure that the object is written to the file, and can be read from the file into the program.

2.3 Read and write file-related code. Critical lines need to be annotated.

For:

3. Code volume Statistics 3.1 Statistics the amount of code completed this week

The weekly code statistics need to be fused into a single table.

Week Time Total code Amount New Code Volume total number of files number of new files
2 141 141 6 6
3 445 380 10 3
5 871 426 16 6
6 1496 623 26 10
7 2570 1076 40 14
8 2674 104 46 6
9 2997 323 53 7
10 3313 316 58 5
11 3724 411 68 10
12 4249 525 78 10
13 4540 291 87 9
Option: 4. Flow and Document Learning Guide (the job content is all selected at the bottom) 1. Character 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.

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.3 If the println method of PrintWriter is called, but not close at the back. What is the file size? Why?
    • Reference: Topic specific requirements see flow and document Experimental task book-title 1-2.1
    • Reference code:TextFileTest.java
2. Buffer Stream 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 to read data 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

For:

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.
    • Reference: Subject specific requirements see flow and Document Experiment Task Book-topic 1-2.2 to 2.3
    • Reference code:BufferedReaderTest.java

JUNIT4 frequently used annotations
JUNIT4 Learning
JUNIT4 Reference

201621123034 Java programming 12th Week of study summary

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.