Serveur: tomcat.FilenotfoundExcption dans JAVAEE Eclipse
J'ai créé une servlet pour appeler le programme JAVA afin de traiter le fichier CSV.
Le nouveau code ToJSON(). Main (fichiers) traitera les fichiers csv vers json.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String [] files = request.getParameter("files").split(",");
System.out.println(String.join(",", files));
new ToJSON().main(files);
////call the java program to convert CSV files to json then sent the file name or the contain back.
response.getWriter().append("data.json");
}
SEVERE: Servlet.service() for servlet [charting.servlet.ChartingServlet] in context with path [/Charting] threw exception
java.io.FileNotFoundException: BankFileLine.csv (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at format.LoadCSVFile.iterable(LoadCSVFile.java:60)
at format.LoadCSVFile.getMaxLength(LoadCSVFile.java:44)
at format.LoadCSVFile.<init>(LoadCSVFile.java:26)
at toJSON.ToJSON.main(ToJSON.java:26)
Mais j'ai continué à obtenir filenotfoundexception. J'ai essayé de mettre les fichiers dans WebContent et src. aucun d'eux n'a travaillé. J'ai essayé d'ajouter le chemin: localhost: 8080/ChartingServlet/filename, ne fonctionnait toujours pas.
Voici les répertoires Here is the directories of the project files
Ma question est là où je devrais mettre les fichiers?
Indiquez le chemin absolu vers les fichiers. Vous ne pouvez pas compter sur le répertoire de travail actuel. –