[BAEL-14274] - Fixed article code for https://www.baeldung.com/spring-classpath-file-access
This commit is contained in:
parent
783a93fb47
commit
ce8f3f54c5
|
@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -77,7 +78,7 @@ public class SpringResourceIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void whenResourceUtils_thenReadSuccessful() throws IOException {
|
||||
final File employeeFile = ResourceUtils.getFile("classpath:data/employees.dat");
|
||||
final File employeeFile = loadEmployeesWithSpringInternalClass();
|
||||
final String employees = new String(Files.readAllBytes(employeeFile.toPath()));
|
||||
assertEquals(EMPLOYEES_EXPECTED, employees);
|
||||
}
|
||||
|
@ -112,4 +113,8 @@ public class SpringResourceIntegrationTest {
|
|||
final String employees = new String(Files.readAllBytes(resource.toPath()));
|
||||
assertEquals(EMPLOYEES_EXPECTED, employees);
|
||||
}
|
||||
|
||||
public File loadEmployeesWithSpringInternalClass() throws FileNotFoundException {
|
||||
return ResourceUtils.getFile("classpath:data/employees.dat");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue