Lecture 21 - File Input and Output

Lecture 21 - File Input and Output - File Input and Output...

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

View Full Document Right Arrow Icon
File Input and Output Streams and Files All I/O in Java is done with streams A stream is a sequence of bytes A stream is independent of its source or destination o Eg: An output stream can go to the screen or to a file, or to another computer across a network (socket) Java provides many classes which represent streams CHECK HANDOUT (cont’d) slide o File Input Stream* Date Input Stream* o BufferedReader* o FileReader* o Last branch, end class Some classes filter streams o Eg: DataInputStream converts a byte stream to a stream of primitive types o File -> FileInputStream -> DataInputStream -> byte byte primitive o A text file consists of a series of bytes, each an ASCII character Can be viewed directly with a text editor To store non-char data, you store a printable version of it Eg: The integer 36 (0x00000024) could be stored with the digits ‘3’ and ‘6’ (0x3336) Int 0000 0000 0000 0000 0000 0000 0010 0100 32 bits, (4 bytes)
Background image of page 1

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

View Full DocumentRight Arrow Icon
o In a binary file, data is stored using the computer’s native binary encoding
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

Lecture 21 - File Input and Output - File Input and Output...

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

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