I managed to implement a simple file I/O in my Spring project for files not inside my project (then WAR
file) using a .properties
file that contains the path (source) and now I need to do it in the server.
Before, when I included the files inside the WAR
file, I can access them in the Tomcat server using the path
/home/my_username/tomcat7/webapps/my_project/WEB-INF/classes/
But now that the files are not inside the WAR
file, I just put them adjacent to the webapps
folder.
The structure of my Tomcat 7 folder is:
tomcat7
|----> bin
|----> conf
|----> logs
|----> resources*
|----> temp
|----> webapps
|--------> springapp.war*
|----> work
where /resources
is the folder I need inside the WAR
file I/O.
My .properties
file has:
dir.server=home/my_username/tomcat7/resources
// or
dir.server=/home/my_username/tomcat7/resources
but an error shows (from my catalina.out
file):
java.io.FileNotFoundException: /home/my_username/tomcat7/resources/my_file.file (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at weka.core.SerializationHelper.read(SerializationHelper.java:270)
Is there a proper way to declare the file path or do I have to change my implementation of file I/O?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…