I'm struggling to access stopwords.txt, a list of stopwords my StopWordRemover
class is using. I can access it just fine using its relative path "./stopwords.txt
" when I run StopWordRemover
as a standalone class, but when I try to use it in the Play application I keep getting FileNotFound Exceptions.
I've also tried:
- moving it into the public folder, and accessing it using controllers.routes.Assets.at(...)
- moving it into the conf folder
^Neither worked.
Where am I going wrong?
Relevant method:
private static void initStopWordList() {
if (stopWords == null) {
stopWordFilePath = "/stopwords.txt";
stopWords = new ArrayList<>();
try {
Stream<String> stream = Files.lines(Paths.get(stopWordFilePath));
stream.forEach(stopWords::add);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Directory path:
app/
service/
StopWordRemover
stopwords.txt