使用 JavaScript 读取 Google Gears blob

发布于 2024-07-25 14:51:27 字数 143 浏览 6 评论 0原文

有谁知道如何在浏览器中读取 google gears blob 对象? 我在 gears 之上使用 gwt,但我正在寻找任何类型的解决方案。 该应用程序需要完全离线工作,因此我无法发布文件并在服务器端处理它们。 我的文件是简单的文本文件,我想在离线模式下上传和解析。

Does anybody know how to read google gears blob objects within the browser? I'm using gwt on top of gears, but I'm looking for any kind of solutions. The application needs to work fully offline so I can't post the files and process them server side. My files are simple text files that I want to upload and parse in offline mode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

靖瑶 2024-08-01 14:51:27

我编写了一个非常简单的类来执行此操作,您可以在这里查看:
http://procbits.com /2009/07/29/read-file-contents-blobs-in-gwt-and-gears/

使用起来非常简单。 要么调用方法“readAllText”,要么您可以逐行读取它。 这是逐行阅读的示例:

try {
    Desktop dt = Factory.getInstance().createDesktop();
    dt.openFiles(new OpenFilesHandler(){
        public void onOpenFiles(OpenFilesEvent event) {
            File[] files = event.getFiles();
            File file = files[0];
            Blob data = file.getBlob();

            BlobReader br = new BlobReader(data);
            while (!br.endOfBlob())
                Window.alert(br.readLine());
        }
    }, true);
} catch (Exception ex){
    Window.alert(ex.toString());
}

我希望这会有所帮助!

I wrote a very simple class to do this you can check it out here:
http://procbits.com/2009/07/29/read-file-contents-blobs-in-gwt-and-gears/

It's very simple to use. Either call the method "readAllText" or you can read it line by line. Here is an example reading line by line:

try {
    Desktop dt = Factory.getInstance().createDesktop();
    dt.openFiles(new OpenFilesHandler(){
        public void onOpenFiles(OpenFilesEvent event) {
            File[] files = event.getFiles();
            File file = files[0];
            Blob data = file.getBlob();

            BlobReader br = new BlobReader(data);
            while (!br.endOfBlob())
                Window.alert(br.readLine());
        }
    }, true);
} catch (Exception ex){
    Window.alert(ex.toString());
}

I hope this helps!

杯别 2024-08-01 14:51:27

您是否查看过 Google Gears API 文档(针对 JavaScript)?

Have you looked at the Google Gears API documentation (for JavaScript)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文