在Google GWT中阅读文本文件? [英] Read text file in google GWT?

查看:115
本文介绍了在Google GWT中阅读文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GWT编写一个网页。现在我需要阅读一个文本文件并在网页上显示内容,但是不了解如何使用GWT。



这是非常好的,如果有任何方式在GWT中我可以读取.properties文件。 (请注意,这不是GWT已经支持的本地化属性文件)



有人有想法吗?



谢谢。

解决方案

您可以使用 RequestBuilder

 新的RequestBuilder(RequestBuilder.GET,path / to / file.txt)sendRequest ,new RequestCallback(){
@Override
public void onResponseReceived(Request req,Response resp){
String text = resp.getText();
// do stuff文本
}

@Override
public void onError(请求res,Throwable throwable){
//处理错误
}
});


I am writing a webpage using GWT. Now I need to read a text file and display the content in the webpage but have no idea how to do that with GWT.

It is very nice if there is any way in GWT that I can read .properties file. (Please note that this is not the properties file of localization that GWT has already supported )

Does anyone have an idea, please?

Thanks.

解决方案

You can read files in your GWT app using RequestBuilder

new RequestBuilder(RequestBuilder.GET, "path/to/file.txt").sendRequest("", new RequestCallback() {
  @Override
  public void onResponseReceived(Request req, Response resp) {
    String text = resp.getText();
    // do stuff with the text
  }

  @Override
  public void onError(Request res, Throwable throwable) {
    // handle errors
  }
});

这篇关于在Google GWT中阅读文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆