Skip to main content

more options

Part 5. Two OO constructs

Module 2, part 6. Reading and writing files

Introduction

Many applications require the ability to read and write files on the computer's hard drive. In Java, this is done using classes in package java.io. This illustrates a useful paradigm of OO programming in Java. Want to add a new kind of functionality? Write a package of classes for it. The basic language remains the same, but a new package allows you to do more. Each version of Java generally comes with more packages. Here are examples of packages:

1. Package java.applet provides classes for creating applets.

2. Package java.net provides classes for implementing networking applications, e.g. an object of class URL is a pointer to a resource on the World Wide Web, like an html page.

3. Package java.security provides classes for security.

4. Package java.text provides classes for handling text, dates, numbers, and messages in a manner that is independent of natural languages.

This module consists basically of a short assignment to get you familiar with reading and writing files. It must be completed before you can take the test for module 2.

Contents

No. Topic Discussion
1. Do the lab on reading and writing files. This is a "lab" and not a real programming assignment. It guides you through a few steps so that you learn quickly about read and writing files. You will have to write two procedures, but they should take only 5-10 minutes each. Then, in the future, if you have to read or write a file, you will know where to look --the class that you will download from the course website.