Class FileReader

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.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:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DONE
      The entire read request has been completed.
      static int EMPTY
      No data has been loaded yet.
      static int LOADING
      Data is currently being loaded.
      private static org.apache.commons.logging.Log LOG  
      private int readyState_  
      private java.lang.Object result_  
      • Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

        CONST, DONTENUM, PERMANENT, READONLY, UNINITIALIZED_CONST
      • Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

        NOT_FOUND
    • Constructor Summary

      Constructors 
      Constructor Description
      FileReader()
      Creates an instance.
    • Field Detail

      • LOG

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

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

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

        private int readyState_
      • result_

        private java.lang.Object result_
    • Constructor Detail

      • FileReader

        public FileReader()
        Creates an instance.
    • Method Detail

      • getReadyState

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

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

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

        public void readAsArrayBuffer​(java.lang.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​(java.lang.Object object,
                               java.lang.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​(java.lang.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​(java.lang.Object onerror)
        Sets the onerror event handler for this FileReader.
        Parameters:
        onerror - the onerror event handler for this FileReader