Using try/catch blocks assignment
Completion requirements
Due: Sunday, 7 December 2003, 12:30 PM
Put the following code (as shown previously) into a file called FileOut.java, compile and run. Note what happens. Now modify the code to remove the code to remove the line with the try{
block on it and remove the code that starts with catch
and ends with
Now attempt to compile and run the code. As your evidence for the assignment create and upload a file describing the results.
block on it and remove the code that starts with catch
and ends with
}catch (Exception e){
System.out.println(e.getMessage());
}
Now attempt to compile and run the code. As your evidence for the assignment create and upload a file describing the results.
import java.io.*;
public class FileOut{
public static void main(String argv[]){
FileOut f = new FileOut();
f.go();
}
public void go(){
try{
FileReader fr = new FileReader("FileOut.java");
int ch;
while((ch = fr.read())> -1){
System.out.print((char) ch);
}
}catch (Exception e){
System.out.println(e.getMessage());
}
}
}