Skip to main content
Open of Course - Free and Open Content Courses and Tutorials
  • Home
  • Calendar
  • Course Categories
    Art & Music Business Computer Applications Computer Programming Languages Operating Systems Webdesign Other Non-English Courses
  • More
Site-wide search Close
Toggle search input
You are currently using guest access
Log in
Open of Course - Free and Open Content Courses and Tutorials
Home Calendar Course Categories Collapse Expand
Art & Music Business Computer Applications Computer Programming Languages Operating Systems Webdesign Other Non-English Courses
Expand all Collapse all

Blocks

Skip Donate

Donate

Flattr this

Donate to Open-Of-Course
  1. Java
  2. Topic 4
  3. Using try/catch blocks assignment

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
 }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());

}
}

}
You are currently using guest access (Log in)
Powered by Moodle