Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File reader in GWT

Tags:

java

file

gwt

i've got the follow issue: I wanna implement a file-reader in my GWT-application which allows the user to upload a file and work with it's content (in this particular case I'm talking about HTML). How do I realize that? As far as I know there is no way to use Java's usual BufferedReader. The only thing I've discovered so far is the following:

        try {
        Request r = new RequestBuilder(RequestBuilder.GET, file).sendRequest("", new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                String text = response.getText();
                System.out.println("1234");
            }

            @Override
            public void onError(Request request, Throwable exception) {
                System.out.println("456");
            }

            });
    } catch (RequestException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But this wouldn't be that helpful as far as there's no file-chooser dialog.

I'd realy appreciate your help!

Regards

like image 387
chollinger Avatar asked Feb 17 '26 13:02

chollinger


1 Answers

There is no ready to use FileReader API in GWT. You can build your own on top of JS Api http://www.html5rocks.com/en/tutorials/file/dndfiles/ for Firefox/Chrome and you'll have to use some kind of plugin for IE (flash for example) in order to make it work everywhere

like image 152
jusio Avatar answered Feb 19 '26 03:02

jusio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!