0

I have an application that uses files.txt to work. When I test the application with a main Class it works but when I deploy it I have this error :

    java.io.FileNotFoundException: keyWords/CA.txt (No such file or directory)
    java.io.FileNotFoundException: keyWords/CA.txt (No such file or directory)
    java.io.FileNotFoundException: keyWords/NormalWords.txt (No such file or directory)

How can I make this work. Thanks !

deltascience
  • 3,321
  • 5
  • 42
  • 71
  • Check the path of the text file. Weather that is accessible from where you have deployed or not? – Rahul Jan 20 '14 at 14:01
  • Put your code here to resolve your error. – Rahul Jan 20 '14 at 14:01
  • Apparently you are accessing the files trough Fileystem directly. Pleas consider Using `ClassLoader#getResource` or `ClassLoader#getResourceAsStream` so that your resources are looked up using the classpath. If this doesn't work then you might show us more code for how you do load those files. – A4L Jan 20 '14 at 14:03
  • The path is correct, when I run the application with : public static void main(String[] args) { String address = "135, avue de pôtrore, IM Insa R 1 31077 tolose"; addressCorrecter correcter = new addressCorrecter(); System.out.println(correcter.correctAddress(address).replaceAll("\n", " ")); } the function CorrectAddress() uses input files to work. When I run the code above it works. But when I try to use the same function in the web app it returns the errors posted. – deltascience Jan 20 '14 at 14:04
  • @TantaouiElMehdi here a related [question/answer](http://stackoverflow.com/a/20775948/1113392) – A4L Jan 20 '14 at 14:07

1 Answers1

0

I resolved the problem by giving complete path: in the ide right click on the file and go to Properties; to get absolute path. Give that path as input file. It works for me. HTH !

deltascience
  • 3,321
  • 5
  • 42
  • 71