How to read local (Client) file with GWT?

回眸只為那壹抹淺笑 提交于 2019-12-22 06:33:12

问题


I would like to use GWT to read and parse local csv file. EDIT: Local file here means client file.

I know I can use HTML5 with javascript to achieve that, but I would like to use GWT to do it.

One way of doing it is by using JavaScript Native Interface (JSNI), however I think it beats the purpose of using GWT.

Another way of doing this would be upload the file to server, and send it back as a json. But I feel it's not the best way of doing it.

Please advise. Thanks.

EDIT: I intend to design a desktop app, so I try to avoid using any web-server scripting.


回答1:


Using jsni doesn't beat the purpose of gwt, sometimes you need to use it as a wrapper to functionality not yet available in gwt or an external javascript library. Instead of writting jsni access to the file api you can use one of several third party libraries available that implement html5 file access, like http://code.google.com/p/lib-gwt-file




回答2:


A quick search returned this SO question: Read text file in google GWT?

Although GWT doesn't support java.io.InputStream, it looks like you could make a request to your CSV File and then parse it.

Remember that if you will host on AppEngine, you won't have a filesystem available so you'll have to have the files hosted elsewhere.



来源:https://stackoverflow.com/questions/6905919/how-to-read-local-client-file-with-gwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!