Personal tools
You are here: Home Classes Fall 2004 - Spring 2005 CS 150 4.22.05 April 22
Document Actions

April 22

by admin last modified 2005-05-11 13:33

Examples from April 22

Today we worked with files and streams:

Copy.java This gets the names of source and destination files from command line arguments. . The buffered read and buffered write abilities of FileReader and FileWriter are used to copy the source into the destination with just two instructions and no loops. For example, to copy the file "Copy.java" into file "CopyOfCopy" you would use the command java Copy Copy.java CopyOfCopy.

FileStream.java and SimpleInput.java This uses SimpleInput to read strings of text. The stream classes are used to put these strings into a text file, and then to read and print the file.

SystemStream.java This uses streams to read strings of text from the user; these strings are added to an array, which at the end is printed out. Note that this makes no use of the SimpleInput class. This is the first example we have done of reading text from the keyboard using native java methods.

 

 

 

 

 

 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: