Lecture note Java methods A & AB: Object-oriented programming and data structures: Chapter 14 - Maria Litvin, Gary Litvin

Chapter 14 - 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. | Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Streams and Files ("Chapter %d", 14); 14- 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 14- 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 E). 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 . | Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Streams and Files ("Chapter %d", 14); 14- 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 14- 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 E). 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. 14- 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. 14- 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). 14- The file name may give a hint as to how it “prefers” to be treated. Surely,

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.