Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to open a file?
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?
Which page is it in the book?
I have the kindle version which is not showing the pages but I can tell you that it is chapter 5, project boxwords, and file Dictionary.java
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.
Can you explain your answer a little more?I am using Tomcat 7 latest version.
Thank you again for your answer.