Example usage for com.google.gwt.file.client File getResult

List of usage examples for com.google.gwt.file.client File getResult

Introduction

In this page you can find the example usage for com.google.gwt.file.client File getResult.

Prototype

public final native String getResult();

Source Link

Document

On getting, the result attribute returns a Blob's data as a DOMString, or as an ArrayBuffer [TypedArrays], or null, depending on the read method that has been called on the FileReader, and any errors that may have occurred.

Usage

From source file:org.rest.client.task.DefinitionsErrorDialog.java

License:Apache License

private void parseFile() {
    if (fileImport.getFiles().size() == 0)
        return;/*from  w w w .  jav  a  2s  .c  o  m*/
    cancel.setEnabled(false);
    File file = fileImport.getFiles().get(0);
    FileReader reader = FileReader.create();
    reader.addLoadHandler(new LoadHandler() {
        @Override
        public void onLoad(File file) {
            result = file.getResult();
            dialog.hide();
        }
    });
    reader.addErrorHandler(new ErrorHandler() {
        @Override
        public void onError(File file, FileError error) {
            errorField.setInnerText("Unable read file :(");
            errorField.removeClassName("hidden");
            cancel.setEnabled(true);
        }
    });
    reader.readAsText(file);
}