我需要读取服务器上的文件,但我发现在GWT中无法使用某些Java库。
我该怎么办?

最佳答案

尝试 requestBuilder !此代码可以帮助吗?

        RequestBuilder requestBuilder = new RequestBuilder( RequestBuilder.GET, "yourfile.txt" );
        try {
            requestBuilder.sendRequest( null, new RequestCallback(){
                public void onError(Request request, Throwable exception) {
                    GWT.log( "failed file reading", exception );
                }

                public void onResponseReceived(Request request, Response response) {
                    String result=response.getText();

                }} );
        } catch (RequestException e) {
            GWT.log( "failed file reading", e );
        }

10-04 11:45