Skip to content

Commit f12e6ee

Browse files
author
Grzegorz Piwowarek
committed
Refactor FileNotFoundException examples
1 parent 0dc8119 commit f12e6ee

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎core-java/src/test/java/org/baeldung/core/exceptions/FileNotFoundExceptionTest.java‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package org.baeldung.core.exceptions;
22

3-
import java.io.BufferedReader;
4-
import java.io.File;
5-
import java.io.FileNotFoundException;
6-
import java.io.FileReader;
7-
import java.io.IOException;
8-
93
import org.apache.log4j.Logger;
104
import org.junit.Test;
115

6+
import java.io.*;
7+
128
public class FileNotFoundExceptionTest {
139

1410
private static final Logger LOG = Logger.getLogger(FileNotFoundExceptionTest.class);
@@ -49,15 +45,14 @@ public void logError() throws IOException {
4945
}
5046
}
5147

52-
protected void readFailingFile() throws IOException {
53-
BufferedReader rd = null;
54-
rd = new BufferedReader(new FileReader(new File(fileName)));
48+
private void readFailingFile() throws IOException {
49+
BufferedReader rd = new BufferedReader(new FileReader(new File(fileName)));
5550
rd.readLine();
5651
// no need to close file
5752
}
5853

59-
class BusinessException extends RuntimeException {
60-
public BusinessException(String string, FileNotFoundException ex) {
54+
private class BusinessException extends RuntimeException {
55+
BusinessException(String string, FileNotFoundException ex) {
6156
super(string, ex);
6257
}
6358
}

0 commit comments

Comments
 (0)