From f12e6ee2d032e939dfbe212121248a5c90856c60 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Tue, 4 Oct 2016 18:11:37 +0200 Subject: [PATCH] Refactor FileNotFoundException examples --- .../exceptions/FileNotFoundExceptionTest.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/core-java/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionTest.java b/core-java/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionTest.java index 9180edfe81..5675fe274e 100644 --- a/core-java/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionTest.java +++ b/core-java/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionTest.java @@ -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); } }