M/F 2:30-3:20   
in G01 Gates Hall

CS 1130: Transition to OO Programming

Spring 2016

Part 5. Advanced OO Concepts

Module 1, Part 6

Reading and Writing Files

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.


Contents

1. Lab for Reading and Writing Files

Lab Instructions

Comments: 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.