• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
11 views

Problem:

When you open a file with the printwriter class, the class can potentially throw an ioexception.

by (3.2k points)  

1 Answer

0 votes

Solution:

static void printWriteDemo(){

  try{

    PrintWriter out = new PrintWriter(new FileWriter("Test.txt"));

  }catch(IOException ex){

    throw new RuntimeException("Writing issues: "+ex.getMessage(), ex);

  }

}

Further Reading:

http://wiki2.juneday.se/mediawiki/index.php/Chapter:Exceptions_-_Code_examples

by (300 points)  
...