0

I'm working on a project where I open a file, overwrite it, and save it as a new file. However, I'm having some difficulties with accessing the template file.

Right now, I believe my program is referencing the file using the path from my computer, however, if I were to export this program to a different computer, it probably couldn't find the file.

I have the file stored in a source folder for the project in eclipse. Is there a correct way to reference the file so that it will be able to be found on any computer?

I've attached an image on how my program is now referencing the file.

enter image description here

2 Answers 2

1

If the file is in the project folder, you don't need to specify a path at all. Simply using the filename "file.txt" can suffice where you would have normally put a path.

Sign up to request clarification or add additional context in comments.

Comments

0

One alternative can be if you are using Tomcat server for deployment , then place this file in web-apps location of tomcat.

Accessing will be done using below code snippet

String filePath = System.getProperty("catalina.base") + "/web-apps";

This filePath will work on all computers because we set catalina base in all machines installing tomcat.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.