File IO (15) - COP 3330: Object-Oriented Programming Summer...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3330: Java I/O Page 1 © Dr. Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2011 Java I/O Department of Electrical Engineering and Computer Science Computer Science Division University of Central Florida Instructor : Dr. Mark Llewellyn markl@cs.ucf.edu HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: Java I/O Page 2 © Dr. Mark Llewellyn Reading and Writing in Java The vast majority of computer programs require information to be entered into them, and programs usually provide some form of output information. Early in this course you created output using the simple print() and println() methods of the java.lang.System class and more recently you’ve graduated to using the options available via GUIs. Many programs rely on input information being contained in a data file that the program must read and process. In turn, the program writes information to an output file. File I/O is often used in conjunction with standard I/O, e.g. console output and keyboard input.
Background image of page 2
COP 3330: Java I/O Page 3 © Dr. Mark Llewellyn Reading and Writing in Java (cont.) • Java provides many classes to perform the program input and output. Program I/O refers to any I/O performed by the program. File I/O refers specifically to I/O performed on files. • Program I/O can come from or be sent to the monitor screen, data files, network sockets, or the keyboard.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: Java I/O Page 4 © Dr. Mark Llewellyn Reading and Writing in Java (cont.) Java designers constructed program I/O to be based on three principles: 1. The input and output is based on streams that have a physical device at one end, such as a disk file, and data streams into or out of the program in a flow of characters or bytes. Classes are used to manage how the data comes into or leaves a program. 2. I/O should be portable and should obtain consistent results even though the underlying hardware platforms may differ. 3. Java provides many classes that each perform a few tasks instead of large classes that do many things.
Background image of page 4
COP 3330: Java I/O Page 5 © Dr. Mark Llewellyn Streams A way to visualize data flowing into or out of a Java program is to envision a stream of characters or a data pipeline. This stream of data is linked to a physical device, such as a file stored on the hard drive to a network socket. Java program apples, eggs, gummi bears, peppers, milk, tea, pears File shoppinglist.txt on disk. apples, eggs stream of characters
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: Java I/O Page 6 © Dr. Mark Llewellyn Streams (cont.) • There are two types of streams in Java, byte streams and character streams . • Byte streams pump the data into and out of programs as bytes. Byte stream classes are used for handling these bytes. Binary data are stored either as 8-bit bytes or as an ASCII character code set. • Character streams
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 66

File IO (15) - COP 3330: Object-Oriented Programming Summer...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online