1. Summary of this week's study
1.1 Summarize multiple streams 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?
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.
Option: 3. Try to design a search engine system for the computer Academy website (Team completion)
You can start with the console only, not necessarily with the web.
3.1 The system is probably divided into several parts, each part to complete what function?
3.2 What is the entire workflow of the system. What is the relationship between the various parts. You can try drawing description.
3.3 What knowledge is needed to complete the system?
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 |
| 1 |
44 |
44 |
2 |
2 |
| 2 |
213 |
213 |
10 |
5 |
| 3 |
417 |
204 |
10 |
5 |
| 5 |
676 |
259 |
17 |
7 |
| 6 |
1071 |
405 |
24 |
7 |
| 7 |
1780 |
709 |
30 |
6 |
| 8 |
1900 |
120 |
35 |
5 |
| 9 |
2335 |
435 |
41 |
6 |
| 10 |
2767 |
432 |
48 |
7 |
| 11 |
3321 |
595 |
57 |
9 |
| 12 |
3601 |
280 |
63 |
6 |
| 13 |
3821 |
220 |
67 |
4 |
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)
1.2 What is the size of the generated file (using the right-click File Properties view)? Analyze the file size
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 reading data from the file using BufferedReader with scanner, which method is 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
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.
3. Character encoding
3.1 Existing EncodeTest.txt file, 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)
3.2 Writing methods convertGBK2UTF8(String src, String dst) , you can convert the GBK encoded source file src to a UTF8 encoded destination file for DST.
- Reference:
InputStreamReaderTest.java with teaching ppt
4. Byte stream, binary file: DataInputStream, DataOutputStream, ObjectInputStream
4.1 Refer to the DataStream directory related code, try to write the data of three student objects to the file, and then read from the file and display. (Key code, occurrence number)
4.2 The file generated here and Topic 1 generated files why not the same? How large is the generated file? Parse the file size? Compare the file size to the file generated by topic 1 is it big or small, why? When it comes to storing data, is it easier to save space in binary files or text files? What are the benefits of using a binary storage file?
4.3 Use the Wxmedit 16 binary mode (or the 16 binary mode of other text editors) to open Student.data and analyze how the data is stored in the file.
4.4 Use ObjectInputStream (read), ObjectOutputStream (write) Read and write students. (Key code, Advent Number)//reference Objectstreamtest Directory
- Reference: Topic specific requirements See flow and document experimental task book-title 1-1
5. Scanner Basic Concept Assembly object
Writes public static List<Student> readStudents(String fileName) All students from the text file specified by filename and puts it in a list. Should I use those IO-related classes? Tell me about your reasons for choosing.
- Lab File: Students.txt
- Reference: Under the Textfiletest directory
TextFileTest.java
6.
Choice: Randomaccessfile
6.1 Using Randomaccessfile to achieve topic 1.1. (Key code, occurrence number)
6.2 Analyzing file sizes
6.3 Write a function public Student getStuByIndext(int index) that can use Randomaccessfile to remove the student's information from the file according to the ordinal index. (The key code, the occurrence of the school number). And answer, where is the randomaccessfile of the random access characteristics of the file.
- Reference: In the Randomfiletest directory
RandomFileTest.java
- Expand reading: How to use nio.2 to do random file access. Reference-random Access Files
7. File operation
Write a program, according to the specified directory and file name, search for the directory and all files under the subdirectory, if the specified file name is not found, then show no match, otherwise all the found file names and folder names are displayed.
7.1 Write the public static void findFile(String path,String filename) function, the path specified by path is the root directory, using recursion, in its directory and subdirectories to find all and filename the same file name, once found on the output to the console immediately. (Key code, occurrence number)
7.2 Use the queue, use the graphical interface, complete with Java nio.2 (optional 1)
7.3 Choose: Performance test, Test your findfile to find the speed of matching files. There are solutions that can make finding faster. such as Everything a similar search speed.
7.4 Optional: Implementation deletes the specified directory (if the directory is not empty, delete all files and directories under that directory and its subdirectories).
- Reference code:
FindDirectories.java
- Reference: Topic specific requirements See Flow and Document Experiment task Book-Title 2
7.5 Select: Convert all files in the specified directory and subdirectories .java into UTF-8 encoded format and test.
- Reference: Determining the encoding format of a file
7.6 Choose to do advanced: Fork in the Code statistics project, review code, and give advice. If possible, you can also add new features andPull Request
8. Regular expressions
8.1 Use regular expressions to determine if a given string is a 10-digit format? Try programming to validate, to give the test data set and run the result (can be converted to PTA). (Key code, occurrence number)
8.2 Explain the regular expression you wrote.
8.3 Choose to do: Modify the Hrefmatch.java, try to match the number string in the Web page, match the picture string in the Web page. (can be converted to PTA)
- Reference: Specific requirements of the topic see Flow and Document Experimental task book-Title 3
8.4 Choose to do (more difficult): further transformation of the above program, to obtain a link to the picture, such as IMG src="images/mail1.gif" , and then processed to generate the actual link address of the picture http://cec.jmu.edu.com/images/mail1.gif . Finally, several addresses are generated and placed in a queue. Write the method, you can follow the queue of all the picture address, one time to download the picture.
- References: Regular expression reference articles
5. Optional: Extracurricular reading
5.1 Trying to translate the Summary in Lesson:basic I/O
5.2 Attempt to complete questions and Exercise
5.3
Character Set and encoding
5.4
Syntax and examples for Java regular expressions
201621123042 Java Programming 12th operations