I am running a web application using Jersey. In my controller, I am trying to get a file in src/main/resources folder.
When the file is being fetched, I am getting a java.io.FileNotFoundException: src\main\resources\tsv\ProductValid.tsv (The system cannot find the path specified)
My folder structure is:
My gradle dependencies are:
dependencies {
implementation group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: '3.0.2'
implementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '3.0.2'
implementation group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy', version: '3.0.2'
}
My code is:
@GET
@Path(value = "/log/details/{fileId}")
@Produces(MediaType.APPLICATION_JSON)
public List<IngestionLogs> getIngestionLogDetails(@PathParam("fileId") String fileId) {
List<IngestionLogs> logs = new ArrayList<>();
try {
String key = "Physical/STP_20201214.tsv";
File file = new File("src/main/resources/tsv/ProductValid.tsv");
InputStream stream = new FileInputStream(file);
List<IngestionLogs> errors = TsvFileValidators.parseObject(stream);
logs.addAll(errors);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return logs;
}
How do I fix this error?