0% found this document useful (0 votes)
57 views

Lab - Exp - 10 (Creating, Reading and Writing A File Using Input and Output Streams)

Uploaded by

KarlGabriel
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Lab - Exp - 10 (Creating, Reading and Writing A File Using Input and Output Streams)

Uploaded by

KarlGabriel
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

COLLEGE OF COMPUTER STUDEIS

INFORMATION TECHNOLOGY DEPARTMENT

CCS0023L
(Object Oriented Programming)

EXERCISE

10
Creating, Reading and Writing a File Using Input and
Output Streams

Student Name / Group


Karl Gabriel R. Jarilla
Name:
Name Role
Members (if Group):

Section: AN23
Professor: Ms. Lacuesta

I. PROGRAM OUTCOME/S (PO) ADRESSED BY THE LABORATORY EXERCISE


a. Apply knowledge of computing appropriate to the discipline.
II. COURSE LEARNING OUTCOME/S (CLO) ADDDRESSED BY LABORATORY
EXERCISE
2 Apply knowledge of computing fundamentals and develop computer programs as a result of
evaluating possible alternative program constructs that will address the need for automating
real life tasks, taking into account the efficiency and effects of their choice of constraints.

III. INTENDED LEARNING OUTOME/S (ILO) ADDRESSES BY THE LABORATORY


EXERCISE
 Implement Input and Output stream in creating, reading and writing streams

IV. BACKGROUND INFORMATION

There are generally two types of streams, the character and byte streams. Let us just review the
basic difference between the two. Byte streams are file or device abstractions for binary data
while character streams are for Unicode characters.

The InputStream class is the abstract root class of all input byte streams whereas the
OutputStream class is the abstract root class of all output byte streams. For character streams, the
corresponding superclass of all classes are the Reader and the Writer class, respectively. Both
classes are abstract classes for reading and writing to character streams.

Streams are also categorized on whether they are used for reading or writing to streams.
Although it is already quite obvious, allow me to define these types of streams. You are allowed
to read from input streams but not write to them. On the other hand, you are allowed to write to
output streams but not read from them.
The InputStream class and the Reader class are the superclasses of all input streams.
The OutputStream class and the Writer class are the root classes of all output streams.

Input streams are also known as source streams since we get information from these
streams. Meanwhile, output streams are also called sink streams.

A node stream is a stream with the basic functionality of reading or writing from a specific
location such as a disk or from the network. Types of node streams include files, memory and
pipes. Filter streams, on the other hand, are layered onto node streams between threads or
processes to provide additional functionalities not found in the node stream by themselves.
Adding layers to a node stream is called stream chaining.
V. EXPERIMENTAL PROCEDURE:

1. Create a program that writes an Integer object to a stream and reads this object
from the stream.

2. Simple Encryption. Read from a file specified by the user and encrypt the content
of the file using a simple shifting technique. Also, ask the user to input the shift
size. Output the encrypted message to another file whose filename is also provided
by the user.

For example,
Shift size: 1
Message read from the file: Hello
Encrypted message: Ifmmp

1.
2.
VI. QUESTION AND ANSWER:

1. What is the difference between node and filter streams?


- Node streams and filter streams serve different purposes in Java’s I/O system. Node
streams are the basic building blocks for interacting directly with data sources or
destinations, such as files, memory, or network connections. They provide essential
functionality for reading from or writing to these locations, with examples like
FileInputStream and FileOutputStream. On the other hand, filter streams are used to add extra
functionality to node streams without modifying the underlying data source or
destination. They enhance data processing by providing features like buffering,
encryption, or formatting. For example, BufferedInputStream is a filter stream that adds
buffering to an input stream, improving performance. While node streams handle the
actual data transfer, filter streams operate on the data as it flows through, providing
additional capabilities like buffering or data manipulation.
- Note: The following rubrics/metrics will be used to grade students’ output in the lab
Exercise 10.

Program (100 pts.) (Excellent) (Good) (Fair) (Poor)


Program Program executes Program executes Program executes Program does not
execution (20pts) correctly with no with less than 3 with more than 3 execute (10-11pts)
syntax or runtime errors (15-17pts) errors (12-14pts)
errors (18-20pts)
Correct output Program displays Output has minor Output has Output is incorrect
(20pts) correct output errors (15-17pts) multiple errors (10-11pts)
with no errors (12-14pts)
(18-20pts)
Design of output Program displays Program displays Program does not Output is poorly
(10pts) more than minimally display the designed (5pts)
expected (10pts) expected output required output (6-
(8-9pts) 7pts)
Design of logic Program is Program has slight Program has Program is
(20pts) logically well logic errors that do significant logic incorrect (10-
designed (18- no significantly errors (3-5pts) 11pts)
20pts) affect the results
(15-17pts)
Standards Program code is Few inappropriate Several Program is poorly
(20pts) stylistically well design choices inappropriate written (10-11pts)
designed (18- (i.e. poor variable design choices
20pts) names, improper (i.e. poor variable
indentation) (15- names, improper
17pts) indentation) (12-
14pts)
Delivery The program was The program was The program was The program was
(10pts) delivered on time. delivered a day delivered two days delivered more
(10pts) after the deadline. after the deadline. than two days after
(8-9pts) (6-7pts) the deadline. (5pts)

Topic Input and Output Stream


Lab Activity No 10a
Lab Activity Writing Int Object in a File
CLO 2
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL

Topic Input and Output Stream


Lab Activity No 10b
Lab Activity Simple Encryption
CLO 2
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL

You might also like