I'm trying to read a excel file in a singleton so it is loaded only once.
The excel file and the singleton are in the same package but getResourceAsStream
returns null
.
What could I be missing ?
public static synchronized HSSFWorkbook getUniqueInstance(String fileStr) {
if (sInstance == null) {
try {
InputStream file = WBSingleton.class.getResourceAsStream(fileStr);
sInstance = new HSSFWorkbook(file);
} catch (IOException e) {
e.printStackTrace();
}
}
return sInstance;
}