janetsmith
janetsmith

Reputation: 8722

How to read local (Client) file with GWT?

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.

Upvotes: 5

Views: 7714

Answers (2)

Hilbrand Bouwkamp
Hilbrand Bouwkamp

Reputation: 13519

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

Upvotes: 7

citizen conn
citizen conn

Reputation: 15390

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.

Upvotes: -1

Related Questions