Class FileReader

java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

public class FileReader extends EventTarget
A JavaScript object for FileReader.
See Also:
  • Field Details

    • LOG

      private static final org.apache.commons.logging.Log LOG
    • EMPTY

      public static final int EMPTY
      No data has been loaded yet.
      See Also:
    • LOADING

      public static final int LOADING
      Data is currently being loaded.
      See Also:
    • DONE

      public static final int DONE
      The entire read request has been completed.
      See Also:
    • readyState_

      private int readyState_
    • result_

      private Object result_
  • Constructor Details

    • FileReader

      public FileReader()
      Creates an instance.
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
      Overrides:
      jsConstructor in class EventTarget
    • getReadyState

      public int getReadyState()
      Returns the current state of the reading operation.
      Returns:
      0, 1, or 2
    • getResult

      public Object getResult()
      Returns the file's contents.
      Returns:
      the file's contents
    • readAsDataURL

      public void readAsDataURL(Object object) throws IOException
      Reads the contents of the specified Blob or File.
      Parameters:
      object - the Blob or File from which to read
      Throws:
      IOException - if an error occurs
    • readAsArrayBuffer

      public void readAsArrayBuffer(Object object)
      Reads the contents of the specified Blob or File.
      Parameters:
      object - the Blob or File from which to read
    • readAsText

      public void readAsText(Object object, Object encoding)
      Reads the contents of the specified Blob or File. When the read operation is complete, the readyState is changed to DONE, the loaded event is triggered, and the result attribute contains the contents of the file as a text string.
      Parameters:
      object - the Blob or File from which to read
      encoding - the encoding
    • getOnload

      public org.htmlunit.corejs.javascript.Function getOnload()
      Returns the onload event handler for this FileReader.
      Returns:
      the onload event handler for this FileReader
    • setOnload

      public void setOnload(Object onload)
      Sets the onload event handler for this FileReader.
      Parameters:
      onload - the onload event handler for this FileReader
    • getOnerror

      public org.htmlunit.corejs.javascript.Function getOnerror()
      Returns the onerror event handler for this FileReader.
      Returns:
      the onerror event handler for this FileReader
    • setOnerror

      public void setOnerror(Object onerror)
      Sets the onerror event handler for this FileReader.
      Parameters:
      onerror - the onerror event handler for this FileReader