Streams of primitive elements


Write out a series of primtive elements and read them back in, checking for consistency.

Details of input and output streams are covered in the course notes.

Work Location

Perform all work for this magercise in VisualAge project MageLang Magercises, package magercises.Streams of Primitive Elements.

If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name.

Tasks

Perform the following tasks:

  1. Open a DataOutputStream to file junk. Write out the following elements:
    		int: 34
    		String: "hello"
    		double: 3.14159
    		byte: 2
    

  2. Close the file and read the values back in. Use DataInputStream.

  3. Verify that the values read in are the same that were written. Print "ok" or "not ok" for each consistency check.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.