UHCL CSCI 3134 - Files and Streams (19 pages)

Previewing pages 1, 2, 3, 4, 5, 6 of 19 page document View the full content.
View Full Document

Files and Streams



Previewing pages 1, 2, 3, 4, 5, 6 of actual document.

View the full content.
View Full Document
View Full Document

Files and Streams

27 views

Other


Pages:
19
School:
University of Houston-Clear Lake
Course:
Csci 3134 - Software Development With Java

Unformatted text preview:

Files and Streams Based on slides from Deitel Associates Inc Revised by T A Yang 1 Outline Streams Files Text files vs Binary files Related Java classes java io FileReader for reading streams of characters java io FileWriter for writing streams of characters java io File for handling file attributes folders etc java io InputStream for reading streams of raw bytes java io FileInputStream java io ObjectInputStream java io OutputStream for writing streams of raw bytes java io FileOutputStream java io ObjectOutputStream 2 3 17 1 Introduction Why use files Data stored in variables and arrays are temporary in memory For long term retention of data computers use files Computers store files on secondary storage devices hard disks optical disks flash drives and magnetic tapes Data maintained in files are persistent data because they exist beyond the duration of program execution 4 Java views each file as a sequential stream of bytes Every operating system provides a mechanism to determine the end of a file such as an end of file marker or a count of the total bytes in the file A Java program simply receives an indication from the operating system when it reaches the end of the stream system independent How about objects in your program Can they be saved in files and retrieved later 5 Text vs Binary Files File streams can be used to input and output data as bytes or characters Streams that input and output characters are known as character based streams representing data as a sequence of characters Files created using character based streams are referred to as text files Text files can be read by text editors Streams that input and output bytes are known as byte based streams representing data in its binary format Files that are created using byte based streams are referred to as binary files Binary files are read by programs that understand the specific content of the file and the ordering of that content 6 Java programs perform file processing by using classes from package



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Files and Streams and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Files and Streams and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?