Назад | Начало урока | Вперед
Содержание

Глава 3

class Filer


/* The Filer class by J M Bishop June 2000
* ---------------------- Java 1.2
* based on the FileMan class
* from June 1997
*
* Provides for a file to be opened, with five tries at a
* correct file name.
* Illustrates the use of exceptions in for-try loops..
*/
package javagently;

import java.io.*;

public class Filer {

public static Stream open (String filename) throws IOException {
Stream in = new Stream (System.in); try {
return new Stream(filename, Stream.READ);
}
catch (FileNotFoundException e) {
System.out.println(filename+" does not exist."); filename = in.readString();
}
throw new FileNotFoundException ();
}
}


Назад | Начало урока | Вверх | Вперед
Содержание

Hosted by uCoz