B2G/gecko/toolkit/content/tests/browser/browser_save_resend_postdata.js
/**
 * Reads the contents of the provided short file (up to 1 MiB).
 *
 * @param aFile
 *        nsIFile object pointing to the file to be read.
 *
 * @return
 *        String containing the raw octets read from the file.
 */
Reads the contents of the provided short file (up to 1 MiB).
@param aFile
nsIFile object pointing to the file to be read.

@return
String containing the raw octets read from the file.
Reads the contents of the provided short file ( up to 1 MiB ) . @param aFile nsIFile object pointing to the file to be read . @return String containing the raw octets read from the file .
function readShortFile(aFile) {
  var inputStream = Cc["@mozilla.org/network/file-input-stream;1"]
                      .createInstance(Ci.nsIFileInputStream);
  inputStream.init(aFile, -1, 0, 0);
  try {
    var scrInputStream = Cc["@mozilla.org/scriptableinputstream;1"]
                           .createInstance(Ci.nsIScriptableInputStream);
    scrInputStream.init(inputStream);
    try {
      return scrInputStream.read(1048576);
    }
    finally {
      scrInputStream.close();
    }
  }
  finally {
    inputStream.close();
  }
}
function readShortFile ( aFile ) { var inputStream = Cc [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Ci . nsIFileInputStream ) ; inputStream . init ( aFile , - 1 , 0 , 0 ) ; try { var scrInputStream = Cc [ "@mozilla.org/scriptableinputstream;1" ] . createInstance ( Ci . nsIScriptableInputStream ) ; scrInputStream . init ( inputStream ) ; try { return scrInputStream . read ( 1048576 ) ; } finally { scrInputStream . close ( ) ; } } finally { inputStream . close ( ) ; } }
Reads the contents of the provided short file (up to 1 MiB).
Reads the contents of the provided short file ( up to 1 MiB ) .
// Assume that the file is much shorter than 1 MiB. // Close the scriptable stream after reading, even if the operation // failed. // Close the stream after reading, if it is still open, even if the read // operation failed.