I am reading a book about vaadin (“Vaadin 7 UI Design by example”) and there is an example in it that creates a word game.
The problem is that I cannot open a file, the way the writer suggests.
Here is the code :
BufferedReader br = new BufferedReader(new FileReader(VaadinServlet.getCurrent().getServletContext().getRealPath("") + "/en_US.dic"));
Debugging the application I found that VaadinServlet.getCurrent().getServletContext().getRealPath(“”) returns null.
Any ideas guys?
Thank you.
The getRealPath method will only return the real path if the translation is possible and allowed. So please check the configuration of the server you’re running on for allowing the translation - and of course that the file is actually available.
If you just need the file as a stream, you could work around by calling ServletContext.getResourceAsStream method.