Created
December 27, 2009 09:41
-
-
Save littlebtc/264223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var writeIntoFile = function(filepath, content, charset) { | |
| var file = Components.classes["@mozilla.org/file/local;1"] | |
| .createInstance(Components.interfaces.nsILocalFile); | |
| file.initWithPath(filepath); | |
| var fostream = Components.classes["@mozilla.org/network/file-output-stream;1"] | |
| .createInstance(Components.interfaces.nsIFileOutputStream); | |
| fostream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); | |
| /* Get a charset converter-enabled stream */ | |
| var costream = Components.classes["@mozilla.org/intl/converter-output-stream;1"] | |
| .createInstance(Ci.nsIConverterOutputStream); | |
| costream.init(fostream, charset, 0, 0x0000); | |
| costream.writeString(content); | |
| /* Close everything */ | |
| cosstream.close(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment