Refactor FileNotFoundException examples

This commit is contained in:
Grzegorz Piwowarek 2016-10-04 18:11:37 +02:00
parent 0dc8119722
commit f12e6ee2d0
1 changed files with 6 additions and 11 deletions

View File

@ -1,14 +1,10 @@
package org.baeldung.core.exceptions;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.junit.Test;
import java.io.*;
public class FileNotFoundExceptionTest {
private static final Logger LOG = Logger.getLogger(FileNotFoundExceptionTest.class);
@ -49,15 +45,14 @@ public class FileNotFoundExceptionTest {
}
}
protected void readFailingFile() throws IOException {
BufferedReader rd = null;
rd = new BufferedReader(new FileReader(new File(fileName)));
private void readFailingFile() throws IOException {
BufferedReader rd = new BufferedReader(new FileReader(new File(fileName)));
rd.readLine();
// no need to close file
}
class BusinessException extends RuntimeException {
public BusinessException(String string, FileNotFoundException ex) {
private class BusinessException extends RuntimeException {
BusinessException(String string, FileNotFoundException ex) {
super(string, ex);
}
}