B2G/gecko/browser/components/sessionstore/src/nsSessionStartup.js
/**
   * reads a file into a string
   * @param aFile
   *        nsIFile
   * @returns string
   */
reads a file into a string
@param aFile
nsIFile
@returns string
reads a file into a string @param aFile nsIFile @returns string
function sss_readFile(aFile) {
    try {
      var stream = Cc["@mozilla.org/network/file-input-stream;1"].
                   createInstance(Ci.nsIFileInputStream);
      stream.init(aFile, 0x01, 0, 0);
      var cvstream = Cc["@mozilla.org/intl/converter-input-stream;1"].
                     createInstance(Ci.nsIConverterInputStream);
      var fileSize = stream.available();
      if (fileSize > MAX_FILE_SIZE)
        throw "SessionStartup: sessionstore.js was not processed because it was too large.";
      cvstream.init(stream, "UTF-8", fileSize, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
      var data = {};
      cvstream.readString(fileSize, data);
      var content = data.value;
      cvstream.close();
      return content.replace(/\r\n?/g, "\n");
    }
    catch (ex) { Cu.reportError(ex); }
    return null;
  }
function sss_readFile ( aFile ) { try { var stream = Cc [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Ci . nsIFileInputStream ) ; stream . init ( aFile , 0x01 , 0 , 0 ) ; var cvstream = Cc [ "@mozilla.org/intl/converter-input-stream;1" ] . createInstance ( Ci . nsIConverterInputStream ) ; var fileSize = stream . available ( ) ; if ( fileSize > MAX_FILE_SIZE ) throw "SessionStartup: sessionstore.js was not processed because it was too large." ; cvstream . init ( stream , "UTF-8" , fileSize , Ci . nsIConverterInputStream . DEFAULT_REPLACEMENT_CHARACTER ) ; var data = { } ; cvstream . readString ( fileSize , data ) ; var content = data . value ; cvstream . close ( ) ; return content . replace ( / \r\n? / g , "\n" ) ; } catch ( ex ) { Cu . reportError ( ex ) ; } return null ; }
reads a file into a string
 @param aFile
        nsIFile
 @returns string
reads a file into a string @param aFile nsIFile @returns string