Your IDE should never determine how you code a program. The IDE won't be available on the production server. Or at least I hope not!
The proper way to read a file that's been bundled into a WAR is to treat it as a WAR resource. I just happen to have some code that will make that easier:
Note that I placed this function in a discrete utilities class. That way my main application code is spared the horror of being laced with framework-specific code.
Note that you should never write to a file in a WAR. Resources in a WAR should be treated as read-only. If you need to write or update, use a directory that's external to both the WAR and to the webapp server.
An IDE is no substitute for an Intelligent Developer.