vocatwk / CodeU-Nemo

Chat web app for CodeU
Apache License 2.0
1 stars 3 forks source link

Update Text File Paths #108

Closed lealgamb closed 6 years ago

lealgamb commented 6 years ago

I'm thinking of placing the text files in webapp since it's where the favicon and index.jsp are located.

yebrahim commented 6 years ago

Those are web resources though, unlike the data file. Do any of the suggestions here work?

lealgamb commented 6 years ago

Will try them out! Sorry for rushing the PR.

lealgamb commented 6 years ago

I've been trying different approaches but I keep getting a FileNotFoundException. I moved the text file to src/main/resources.

File not found exception. Check the stack trace to see what's wrong.
[INFO] java.io.FileNotFoundException: C:\Users\Leal%20Family\CodeU\CodeU-Nemo\target\chatapp-1.0-SNAPSHOT\WEB-INF\classes\NemoBot.txt (The system cannot find the path specified)

image

lealgamb commented 6 years ago

Here's some of the code that handles opening the file

https://github.com/vocatwk/CodeU-Nemo/blob/3ca6e8436c4abac224ad38f71d59622bfca64ac7/src/main/java/codeu/model/data/NemoBot.java#L60-L63

yebrahim commented 6 years ago

Maybe all you need is:

NemoBot nemoBot = new NemoBot(classLoader.getResource("NemoBot.txt").getFile());
lealgamb commented 6 years ago

Still doesn't work. It gets the correct path but can't open the file.

yebrahim commented 6 years ago

Locally or on appengine?

lealgamb commented 6 years ago

Locally. Haven't tried on appengine.

lealgamb commented 6 years ago

I got it to work just now. I'll push the changes for review. Still have to try appengine.