Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Chapter 15 - Streams and files. This chapter’s objectives are to: Learn the basic facts about Java’s IO package, understand the difference between text and binary files, understand the concept of an input or output stream, learn about handling exceptions. | Streams and Files outputFile.printf ("Chapter %d", 15); Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 15- The material in this chapter is not tested on the AP CS exams. Objectives: Learn the basic facts about Java’s IO package Understand the difference between text and binary files Understand the concept of an input or output stream Learn about handling exceptions 15- If you want to learn the technical details about Java’s IO package, this chapter is not sufficient. The main objective here is to provide conceptual background on files and streams, with only a glimpse at their implementation in Java. For student projects, Scanner and PrintWriter are adequate. Or use our EasyReader and EasyWriter (Appendix D). Files A file is a collection of data in mass storage. A data file is not a part of a program’s source code. | Streams and Files outputFile.printf ("Chapter %d", 15); Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 15- The material in this chapter is not tested on the AP CS exams. Objectives: Learn the basic facts about Java’s IO package Understand the difference between text and binary files Understand the concept of an input or output stream Learn about handling exceptions 15- If you want to learn the technical details about Java’s IO package, this chapter is not sufficient. The main objective here is to provide conceptual background on files and streams, with only a glimpse at their implementation in Java. For student projects, Scanner and PrintWriter are adequate. Or use our EasyReader and EasyWriter (Appendix D). Files A file is a collection of data in mass storage. A data file is not a part of a program’s source code. The same file can be read or modified by different programs. The program must be aware of the format of the data in the file. 15- To look at or print out a file you must use some program. Files (cont’d) The files are maintained by the operating system. The system provides commands and/or GUI utilities for viewing file directories and for copying, moving, renaming, and deleting files. The operating system also provides basic functions, callable from programs, for reading and writing directories and files. 15- Recall that a file is a software entity. The hardware knows nothing about files the operating system does. Text Files A computer user distinguishes text (“ASCII”) files and “binary” files. This distinction is based on how you treat the file. A text file is assumed to contain lines of text (for example, in ASCII code). Each line terminates with a newline character (or a combination, carriage return plus line feed). 15- The file name may give a hint as to how it .