GWT:从服务器上的 CSV 文件读取

GWT: reading from a CSV file on the Server

我尝试将旧的 Applet 转换为 GWT 应用程序,但我遇到了以下函数的问题:

    private String[] readBrandList() {
    try {
        File file = new File("Brands.csv");
        String ToAdd = "Default";
        BufferedReader read = new BufferedReader(new FileReader(file));
        ArrayList<String> BrandName = new ArrayList<String>();
        while (ToAdd != null) {
            ToAdd = (read.readLine());
            BrandName.add(ToAdd);
        }
        read.close();
        String[] BrandList = new String[BrandName.size()];
        for (int Counter = 0; Counter < BrandName.size(); Counter++) {
            BrandList[Counter] = BrandName.get(Counter);
        }
        return BrandList;
    } catch (Exception e) {
    }
    return null;
}

现在显然 GWT 不支持 BufferedReader,除了将所有条目写入代码之外,我找不到替换它的方法,这将导致维护噩梦。

是否有任何我不知道或根本不可能实现的功能?

您需要在应用的服务器端读取此文件,然后使用您首选的服务器-客户端通信方法将结果传递给客户端。如果文件很小,您可以读取并传递整个文件,如果文件很大,则可以 read/transfer 分块读取并传递。