File IO: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
No edit summary
(I'll kill him.)
Line 1: Line 1:
=Introduction=
This article describes local file input/output in Javascript.


[http://www.importers-wiki.org/?postid=4 Agriculture Buyers Directory]
You access the filesystem using Mozilla [http://xulplanet.com/tutorials/xultu/xpcom.html XPCOM] components. The list of components used for local IO is available at [http://xulplanet.com/references/xpcomref/group_FilesandStreams.html XulPlanet.com].
[http://www.importers-wiki.org/?postid=5 Animal Extract Buyers ]
[http://www.importers-wiki.org/?postid=5 Animal Extract importers]
[http://www.importers-wiki.org/?postid=6 Animal Fodders Buyers]
[http://www.importers-wiki.org/?postid=6 Animal Fodders importers]
[http://www.importers-wiki.org/?postid=7 Animal Husbandry Buyers  ]
[http://www.importers-wiki.org/?postid=7 Animal Husbandry Importers]
[http://www.importers-wiki.org/?postid=8 Bamboo Products Buyers ]
[http://www.importers-wiki.org/?postid=8 Bamboo Products Importers]
[http://www.importers-wiki.org/?postid=9 Beans Buyers ] 
[http://www.importers-wiki.org/?postid=9 Beans Importers]
[http://www.importers-wiki.org/?postid=10 Charcoal Buyers ] 
[http://www.importers-wiki.org/?postid=10 Charcoal Importers] 
[http://www.importers-wiki.org/?postid=11 Cigarette Buyers  ]
[http://www.importers-wiki.org/?postid=11 Cigarette Importers] 
[http://www.importers-wiki.org/?postid=11 Tobacco buyers  ] 
[http://www.importers-wiki.org/?postid=11 Tobacco distributors]  
[http://www.importers-wiki.org/?postid=12 Farm Machines Buyers] 
[http://www.importers-wiki.org/?postid=12 Tools buyers]
[http://www.importers-wiki.org/?postid=14 Fishery Machinery Buyers] 
[http://www.importers-wiki.org/?postid=14 Fishery Machinery Importers]
[http://www.importers-wiki.org/?postid=15 Flowers Buyers] 
[http://www.importers-wiki.org/?postid=15 Flowers Importers]


[http://www.importers-wiki.org/?postid=16 farm Importers Directory]
==Available libraries==
[http://www.importers-wiki.org/?postid=17 Baby Bed]  
There are a few JavaScript wrappers for IO XPCOM components. See [http://jslib.mozdev.org/ JSLib] and MonkeeSage's [http://gratisdei.com/io.js IO module].
[http://www.importers-wiki.org/?postid=18 Baby Pillow]
MonkeeSage's module is much smaller and very easy to use (simple examples are included in the module).
[http://www.importers-wiki.org/?postid=19 Baby Wipe]  
[http://www.importers-wiki.org/?postid=20 Baby Bib]
[http://www.importers-wiki.org/?postid=21 Baby Playpen]


[http://www.importers-wiki.org/?postid=22 Bib]
=Snippets using XPCOM directly=
[http://www.importers-wiki.org/?postid=23 Baby Blanket]
[http://www.importers-wiki.org/?postid=24 Baby Products]
[http://www.importers-wiki.org/?postid=25 Crib Set]
[http://www.importers-wiki.org/?postid=26 Baby Clothes]
[http://www.importers-wiki.org/?postid=27 Baby Romper]
[http://www.importers-wiki.org/?postid=28 Diaper]
[http://www.importers-wiki.org/?postid=29 Baby Furniture]
[http://www.importers-wiki.org/?postid=30 Baby Shoes]
[http://www.importers-wiki.org/?postid=31 Baby Gifts]
[http://www.importers-wiki.org/?postid=32 Baby Stroller]


[http://www.importers-wiki.org/?postid=33 Automatic Urinal Flusher]
==Creating a file object ("opening" files)==
[http://www.importers-wiki.org/?postid=34 Flush Valve-]
<pre>var file = Components.classes["@mozilla.org/file/local;1"].
[http://www.importers-wiki.org/?postid=35 Shower Mixer]
createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("/home");</pre>


[http://www.importers-wiki.org/?postid=36 Flusher]
Note: the path passed to ''initWithPath()'' should be in 'native' form (eg. <tt>"C:\\Windows"</tt>). If you need to use ''file://'' URIs as initializers, see below.
[http://www.importers-wiki.org/?postid=37 Glass Basin]
[http://www.importers-wiki.org/?postid=38 Shower Panel]
[http://www.importers-wiki.org/?postid=39 Bath Accessories]
[http://www.importers-wiki.org/?postid=40 Hair Dryer]
[http://www.importers-wiki.org/?postid=41 Shower Room]
[http://www.importers-wiki.org/?postid=42 Bath Gloves]
[http://www.importers-wiki.org/?postid=43 Hand Dryer]
[http://www.importers-wiki.org/?postid=44 Sink Mixer]
[http://www.importers-wiki.org/?postid=45 Bath Mat]
[http://www.importers-wiki.org/?postid=46 Hand Held ]
[http://www.importers-wiki.org/?postid=47 Slide Bar]
[http://www.importers-wiki.org/?postid=48 Bath Mixer]
[http://www.importers-wiki.org/?postid=49 Shower Head]
[http://www.importers-wiki.org/?postid=50 Soap Dish]
[http://www.importers-wiki.org/?postid=51 Bath Pillow]
[http://www.importers-wiki.org/?postid=52 Hand Shower ]
[http://www.importers-wiki.org/?postid=53 Soap Dispenser]
[http://www.importers-wiki.org/?postid=54 Bath Toy]
[http://www.importers-wiki.org/?postid=55 Head]
[http://www.importers-wiki.org/?postid=56 Steam Shower ]
[http://www.importers-wiki.org/?postid=57 Bathroom]
[http://www.importers-wiki.org/?postid=58 Lotion Dispenser]
[http://www.importers-wiki.org/?postid=59 Room]
[http://www.importers-wiki.org/?postid=60 Accessories]
[http://www.importers-wiki.org/?postid=61 Massage Bathtub]
[http://www.importers-wiki.org/?postid=62 Tempered Glass ]


Also note, that ''initWithPath()'' / ''initWithFile()'' functions don't throw an exception if specified file does not exist. An exception is thrown when methods that require the file existance are called, e.g. ''isDirectory()'', ''moveTo()'' etc.


==Getting special files==
<pre>// get profile directory
var file = Components.classes["@mozilla.org/file/directory_service;1"].
createInstance(Components.interfaces.nsIProperties).
get("ProfD", Components.interfaces.nsIFile);</pre>


Here are some strings you can put in place of "ProfD" (stolen from MonkeeSage's IO module comments)


{| border="1" cellpadding="5" rules="all"
! String !! Meaning
|-
|ProfD || profile directory
|-
| DefProfRt || user (e.g., /root/.mozilla)
|-
| UChrm || %profile%/chrome
|-
| DefRt || installation
|-
| PrfDef || %installation%/defaults/pref
|-
| ProfDefNoLoc || %installation%/defaults/profile
|-
| APlugns || %installation%/plugins
|-
| AChrom || %installation%/chrome
|-
| ComsD || %installation%/components
|-
| CurProcD ||  installation (usually)
|-
| Home || OS root (e.g., /root)
|-
| TmpD || OS tmp (e.g., /tmp)
|}


Look in the Source for other strings available: [http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsDirectoryServiceDefs.h] [http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsAppDirectoryServiceDefs.h].


==Getting an nsILocalFile from user using nsIFilePicker==
See [[Dev : nsIFilePicker]].


==nsIFile and path strings==
You can use nsIFile::path to get platform-specific path string, eg. <tt>C:\Windows\System32</tt> or <tt>/usr/share</tt>. If you want to get a ''file://'' URL of a file or an nsIFile from ''file://'' URL, you need to use [http://xulplanet.com/references/xpcomref/ifaces/nsIFileProtocolHandler.html nsIFileProtocolHandler]:
<pre>// file is nsIFile
var URL = Components.classes["@mozilla.org/network/protocol;1?name=file"].
createInstance(Components.interfaces.nsIFileProtocolHandler).
getURLSpecFromFile(file);
</pre>


To load from ''file://'', ''http://'', ''chrome://'', ''resource://'' and other URLs directly, use [http://xulplanet.com/references/xpcomref/ifaces/nsIChannel.html nsIChannel]. Until a knowledge base article on [[nsIChannel]] is written, [http://forums.mozillazine.org/viewtopic.php?p=921150#921150 here]'s an example for you.


Note: do '''not''' use nsILocalFile::persistentDescriptor to get the file path!


[http://www.exporters-wiki.org/?postid=3 Houseware Manufacturer]
Also note that generally you don't need to use nsIFile::path. Use nsIFile directly wherever possible. An example below shows how you should save a path in user prefs.
[http://www.exporters-wiki.org/?postid=3 China Houseware]
[http://www.exporters-wiki.org/?postid=4 Baby Products Manufacturer]
[http://www.exporters-wiki.org/?postid=4 Baby Products Exporters]
[http://www.exporters-wiki.org/?postid=5 Bathroom Fittings]
[http://www.exporters-wiki.org/?postid=5 Bathroom Accessories]
[http://www.exporters-wiki.org/?postid=6 Building Products Manufacturer]
[http://www.exporters-wiki.org/?postid=6 Construction Materials ]
[http://www.exporters-wiki.org/?postid=7 Business Equipment]
[http://www.exporters-wiki.org/?postid=7 CCommercial Equipment]
[http://www.exporters-wiki.org/?postid=8 Car Products Manufacturer]
[http://www.exporters-wiki.org/?postid=8  Car Accessories]
[http://www.exporters-wiki.org/?postid=9 Ceramics Manufacturer]
[http://www.exporters-wiki.org/?postid=9  Ceramics Exporters]
[http://www.exporters-wiki.org/?postid=10 Chemicals Manufacturer]
[http://www.exporters-wiki.org/?postid=10  China Chemicals]
[http://www.exporters-wiki.org/?postid=11 Clothing Manufacturer]
[http://www.exporters-wiki.org/?postid=11  Clothing Exporters]
[http://www.exporters-wiki.org/?postid=12 Computer Product Manufacturer]
[http://www.exporters-wiki.org/?postid=12  China Computer Products]
[http://www.exporters-wiki.org/?postid=13 Consumer Electronics]
[http://www.exporters-wiki.org/?postid=13  China Consumer Electronics]
[http://www.exporters-wiki.org/?postid=14 Electrical Equipment ]


[http://www.exporters-wiki.org/?postid=15  Shower Room]
==Saving path in a userpref==
[http://www.exporters-wiki.org/?postid=16  Bath Gloves]
This snippet shows the right way to save a file path in user preferences:
[http://www.exporters-wiki.org/?postid=17  Hand Dryer]
<pre>// |file| is nsILocalFile
[http://www.exporters-wiki.org/?postid=18  Sink Mixer]
var prefs = Components.classes["@mozilla.org/preferences-service;1"].  
[http://www.exporters-wiki.org/?postid=19  Bath Mat]
getService(Components.interfaces.nsIPrefService).  
[http://www.exporters-wiki.org/?postid=20  Hand Held ]
getBranch("extensions.myext.");
[http://www.exporters-wiki.org/?postid=21  Slide Bar]
prefs.setComplexValue("filename", Components.interfaces.nsILocalFile, file);
[http://www.exporters-wiki.org/?postid=22  Bath Mixer]
[http://www.exporters-wiki.org/?postid=23  Shower Head]
[http://www.exporters-wiki.org/?postid=24  Soap Dish]
[http://www.exporters-wiki.org/?postid=25  Bath Pillow]
[http://www.exporters-wiki.org/?postid=26  Hand Shower ]
[http://www.exporters-wiki.org/?postid=27  Soap Dispenser ]
[http://www.exporters-wiki.org/?postid=28  Bath Toy ]
[http://www.exporters-wiki.org/?postid=29  Head ]
[http://www.exporters-wiki.org/?postid=30  Steam Shower]
[http://www.exporters-wiki.org/?postid=31  Bathroom  ]
[http://www.exporters-wiki.org/?postid=32  Lotion Dispenser]
[http://www.exporters-wiki.org/?postid=33  Room ]
[http://www.exporters-wiki.org/?postid=34  Accessories]
[http://www.exporters-wiki.org/?postid=35  Massage Bathtub ]
[http://www.exporters-wiki.org/?postid=36  Tempered Glass]
[http://www.exporters-wiki.org/?postid=37  Bathroom ]
[http://www.exporters-wiki.org/?postid=38  One-Piece Toilet ]
[http://www.exporters-wiki.org/?postid=39  Products ]
[http://www.exporters-wiki.org/?postid=40  Cabinet]
[http://www.exporters-wiki.org/?postid=41  PVC Fitting]
[http://www.exporters-wiki.org/?postid=42  Toilet]
[http://www.exporters-wiki.org/?postid=43  Bathroom Faucet]
[http://www.exporters-wiki.org/?postid=44  Rubber Gloves]
[http://www.exporters-wiki.org/?postid=45  Rubber Gloves]
[http://www.exporters-wiki.org/?postid=46  Toilet Roll Holder]
[http://www.exporters-wiki.org/?postid=47  Bathroom]
[http://www.exporters-wiki.org/?postid=48  Sanitary Ware]
[http://www.exporters-wiki.org/?postid=49  Toilet Seat]
[http://www.exporters-wiki.org/?postid=50  Furniture]
[http://www.exporters-wiki.org/?postid=51  Sensing Faucet]
[http://www.exporters-wiki.org/?postid=52 Toilet Seat Cover]


[http://www.exporters-wiki.org/?postid=53 Bathroom Heater]
/* You can read it later with this statement:
[http://www.exporters-wiki.org/?postid=54 Shower Cap]
var file = prefs.getComplexValue("filename", Components.interfaces.nsILocalFile);
[http://www.exporters-wiki.org/?postid=55 Towel Dispenser]
*/
[http://www.exporters-wiki.org/?postid=56 Bathroom Mirrors]
</pre>
[http://www.exporters-wiki.org/?postid=57 Shower Curtain]
[http://www.exporters-wiki.org/?postid=58 Towel Rack]
[http://www.exporters-wiki.org/?postid=59 Bathroom Racks]
[http://www.exporters-wiki.org/?postid=60 Shower Curtain ]
[http://www.exporters-wiki.org/?postid=61 Towel Ring]
[http://www.exporters-wiki.org/?postid=62 Bathroom Scale]
[http://www.exporters-wiki.org/?postid=63 Rail]
[http://www.exporters-wiki.org/?postid=64 Towel Shelves]
[http://www.exporters-wiki.org/?postid=65 Bathroom Set]
[http://www.exporters-wiki.org/?postid=66 Shower]
[http://www.exporters-wiki.org/?postid=67 Ventilation Fan]
[http://www.exporters-wiki.org/?postid=68 Bathroom Sink]
[http://www.exporters-wiki.org/?postid=69 Enclosure]
[http://www.exporters-wiki.org/?postid=70 Washbasin]
[http://www.exporters-wiki.org/?postid=71 Bathtub]
[http://www.exporters-wiki.org/?postid=72 Shower Faucet]
[http://www.exporters-wiki.org/?postid=73 Washbasin Mixer]
[http://www.exporters-wiki.org/?postid=74 Bidet]
[http://www.exporters-wiki.org/?postid=75 Shower Head]
[http://www.exporters-wiki.org/?postid=76 Water Heater]
[http://www.exporters-wiki.org/?postid=77 Faucet]
[http://www.exporters-wiki.org/?postid=78 Shower Hose]
[http://www.exporters-wiki.org/?postid=79 Flexible Metal]
[http://www.exporters-wiki.org/?postid=80 Shower Mat]
[http://www.exporters-wiki.org/?postid=81 Hose]




==Navigating with nsIFile==


===Get a file in given directory===
Assume, ''file'' is an nsIFile pointing to some directory (f.e. a user profile directory). You can use this code: <tt>file.append("myfile.txt");</tt> - to make ''file'' point to myfile.txt inside that directory.


[http://www.china-wiki.org/archives.php China Manufacturer Directory]
Notes: avoid using <tt>dir.path+"\\"+"myfile.txt"</tt>, as it is not cross-platform code.
[http://www.china-wiki.org/?postid=5 china exporters Directory]
Using something like
[http://www.china-wiki.org/?postid=6 china Factory Directory]
<tt>((path.search(/\\/) != -1) ? path + "\\" : path + "/") + "myfile.txt";</tt>
[http://www.china-wiki.org/?postid=4 china suppliers Directory]
is possible, but the nsIFile::append() is much easier to read and is guaranteed to work on all platforms Mozilla itself works.
[http://www.china-wiki.org/?postid=3 china Manufacturer Directory]
[http://www.china-wiki.org/?postid=7 Agricultural Products]
[http://www.china-wiki.org/?postid=8 AAA Batteries]
[http://www.china-wiki.org/?postid=9 AC Contactors]
[http://www.china-wiki.org/?postid=10 AC DC Adapters]
[http://www.china-wiki.org/?postid=11 Air Circuit Breakers]
[http://www.china-wiki.org/?postid=12 Alkaline Batteries]
[http://www.china-wiki.org/?postid=13 Alnico Magnets]
[http://www.china-wiki.org/?postid=14 Alternators]
[http://www.china-wiki.org/?postid=15 Asynchronous Motors]
[http://www.china-wiki.org/?postid=16 Auto Batteries]
[http://www.china-wiki.org/?postid=17 Ballasts]
[http://www.china-wiki.org/?postid=18 Button Cells]
[http://www.china-wiki.org/?postid=19 Cable Clips ]
[http://www.china-wiki.org/?postid=20 Cable Connectors]
[http://www.china-wiki.org/?postid=21 china exporters Directory]
[http://www.china-wiki.org/?postid=22 Adhesive Fiberglass Tape]
[http://www.china-wiki.org/?postid=23 Fiberglass Screen ]
[http://www.china-wiki.org/?postid=24 Polycarbonate Sheet]
[http://www.china-wiki.org/?postid=25 Aluminum Composite Panel]
[http://www.china-wiki.org/?postid=26 Flexible Metal Hose]
[http://www.china-wiki.org/?postid=27 Porcelain Tile ]
[http://www.china-wiki.org/?postid=28 Aluminum Extrusion ]
[http://www.china-wiki.org/?postid=29 Float Glass ]
[http://www.china-wiki.org/?postid=30 Raised Floor ]
[http://www.china-wiki.org/?postid=31 Floor Drain ]
[http://www.china-wiki.org/?postid=32 Sanitary Ware ]
[http://www.china-wiki.org/?postid=33 Aluminum Profile ]
[http://www.china-wiki.org/?postid=34 Floor Tile ]
[http://www.china-wiki.org/?postid=35 Scaffolding ]
[http://www.china-wiki.org/?postid=36 Ball Bearing Slide]
[http://www.china-wiki.org/?postid=37 Forged Valve]
[http://www.china-wiki.org/?postid=38 Scaffolding Coupler]
[http://www.china-wiki.org/?postid=39 Bamboo Flooring ]
[http://www.china-wiki.org/?postid=40 Gate]
[http://www.china-wiki.org/?postid=41 Bathroom Furniture]
[http://www.china-wiki.org/?postid=42 Geogrid]
[http://www.china-wiki.org/?postid=43 Screen Netting]
[http://www.china-wiki.org/?postid=44 Glass Mosaic Tile]
[http://www.china-wiki.org/?postid=45 Seamless Pipe]
[http://www.china-wiki.org/?postid=46 Bathroom Mirrors]
[http://www.china-wiki.org/?postid=47 Security Door]
[http://www.china-wiki.org/?postid=48 Bathroom Sink]
[http://www.china-wiki.org/?postid=49 Glazed Tiles]
[http://www.china-wiki.org/?postid=50 Shower Curtain Rail]
[http://www.china-wiki.org/?postid=51 Bathtub]
[http://www.china-wiki.org/?postid=52 Granite]
[http://www.china-wiki.org/?postid=53 Blind Rivet]
[http://www.china-wiki.org/?postid=54 Granite Slab]
[http://www.china-wiki.org/?postid=55 Shower Faucet]
[http://www.china-wiki.org/?postid=56 Blinds]
[http://www.china-wiki.org/?postid=57 Granite Tile]
[http://www.china-wiki.org/?postid=58 Shower Head]
[http://www.china-wiki.org/?postid=59 Blockboard]
[http://www.china-wiki.org/?postid=60 Graphite Sheet]
[http://www.china-wiki.org/?postid=61 Shower Hose]
[http://www.china-wiki.org/?postid=62 Brass Fitting]
[http://www.china-wiki.org/?postid=63 Greenhouse]
[http://www.china-wiki.org/?postid=64 Shower Mixer]
[http://www.china-wiki.org/?postid=65 Canopy]
[http://www.china-wiki.org/?postid=66 Gypsum Board]
[http://www.china-wiki.org/?postid=67 Shower Panel]
[http://www.china-wiki.org/?postid=68 Ceiling Board]
[http://www.china-wiki.org/?postid=69 HDPE Pipe]
[http://www.china-wiki.org/?postid=70 Shower Room]
[http://www.china-wiki.org/?postid=71 Ceramic Floor Tile]
[http://www.china-wiki.org/?postid=72 Handle Lock]
[http://www.china-wiki.org/?postid=73 Shutter]
[http://www.china-wiki.org/?postid=74 Handrail]
[http://www.china-wiki.org/?postid=75 Sliding Window]
[http://www.china-wiki.org/?postid=76 Ceramic Tile]
[http://www.china-wiki.org/?postid=77 High Pressure Laminate]
[http://www.china-wiki.org/?postid=78 Smoke Detector]
[http://www.china-wiki.org/?postid=79 Ceramic Wall Tile]
[http://www.china-wiki.org/?postid=80 Solar Water Heater]
[http://www.china-wiki.org/?postid=81 Chopped Strand Mat]
[http://www.china-wiki.org/?postid=82 Hinge]
[http://www.china-wiki.org/?postid=83 Hose Connector]
[http://www.china-wiki.org/?postid=84 Solid Surface]
[http://www.china-wiki.org/?postid=85 Clamp]
[http://www.china-wiki.org/?postid=86 Intercom]
[http://www.china-wiki.org/?postid=87 Spiral Staircase]


===Enumerating files in given directory===
The snippet below makes an array of <tt>|nsIFile|</tt>s corresponding to sub-files/subdirectories of given directory. You can tell files from folders by calling <tt>nsIFile::isDirectory()</tt> and <tt>nsIFile::isFile()</tt> methods on each <tt>|entry|</tt>.


<pre>// file is the given directory (nsIFile)
var entries = file.directoryEntries;
var array = [];
while(entries.hasMoreElements())
{
  var entry = entries.getNext();
  entry.QueryInterface(Components.interfaces.nsIFile);
  array.push(entry);
}</pre>


==Reading from a file==






[http://www.gifts-manufacturers.org gifts manufacturers]
===Simple===
[http://www.gifts-manufacturers.org Gifts Suppliers]
<pre>// |file| is nsIFile
[http://www.gifts-manufacturers.org Gifts Exporters]
[http://www.gifts-manufacturers.org/?postid=3 3D Laser Crystals]
[http://www.gifts-manufacturers.org/?postid=4 Floating Candles]
[http://www.gifts-manufacturers.org/?postid=5 Pet Combs]
[http://www.gifts-manufacturers.org/archives.php Gifts]
[http://www.gifts-manufacturers.org/?postid=6 Air Dancer]
[http://www.gifts-manufacturers.org/?postid=7 Flower Vases ]
[http://www.gifts-manufacturers.org/?postid=8 Pet Feeders]
[http://www.gifts-manufacturers.org/?postid=9 Pet House]
[http://www.gifts-manufacturers.org/?postid=10 Fruit Candle]
[http://www.gifts-manufacturers.org/?postid=11 Pet Products]
[http://www.gifts-manufacturers.org/?postid=12 Artificial Flowers]
[http://www.gifts-manufacturers.org/?postid=13 Gel Candle]
[http://www.gifts-manufacturers.org/?postid=14 Pet Toys]
[http://www.gifts-manufacturers.org/?postid=15 Ashtray]
[http://www.gifts-manufacturers.org/?postid=16 Gift Basket]
[http://www.gifts-manufacturers.org/?postid=17 Photo Album]
[http://www.gifts-manufacturers.org/?postid=18 Gift Box]
[http://www.gifts-manufacturers.org/?postid=19 Photo Frame]
[http://www.gifts-manufacturers.org/?postid=20 Balloon]
[http://www.gifts-manufacturers.org/?postid=21 Gift Wrap]
[http://www.gifts-manufacturers.org/?postid=22 Picture Frame]
[http://www.gifts-manufacturers.org/?postid=23 Bamboo Container]
[http://www.gifts-manufacturers.org/?postid=24 Glass Bottles]
[http://www.gifts-manufacturers.org/?postid=25 Pillar Candle]
[http://www.gifts-manufacturers.org/?postid=26 Bamboo Craft]
[http://www.gifts-manufacturers.org/?postid=27 Glass Candle Holder]
[http://www.gifts-manufacturers.org/?postid=28 Pinwheel]
[http://www.gifts-manufacturers.org/?postid=29 Banner]
[http://www.gifts-manufacturers.org/?postid=30 Glass Candleholder]
[http://www.gifts-manufacturers.org/?postid=31 Plastic Photo Frame]
[http://www.gifts-manufacturers.org/?postid=32 Beach Ball]
[http://www.gifts-manufacturers.org/?postid=33 Glass Chess]
[http://www.gifts-manufacturers.org/?postid=34 Plush Toys]
[http://www.gifts-manufacturers.org/?postid=35 Bead]
[http://www.gifts-manufacturers.org/?postid=36 Glass Lamp]
[http://www.gifts-manufacturers.org/?postid=37 Pocket Knife]
[http://www.gifts-manufacturers.org/?postid=38 Bird Cage]
[http://www.gifts-manufacturers.org/?postid=39 Glass Vase]
[http://www.gifts-manufacturers.org/?postid=40 Puzzle]
[http://www.gifts-manufacturers.org/?postid=41 Bow]
[http://www.gifts-manufacturers.org/?postid=42 Glass Vases]
[http://www.gifts-manufacturers.org/?postid=43 Quartz Clock]
[http://www.gifts-manufacturers.org/?postid=44 Bracelet]
[http://www.gifts-manufacturers.org/?postid=45 Glassware]
[http://www.gifts-manufacturers.org/?postid=46 Quartz Watch]
[http://www.gifts-manufacturers.org/?postid=47 Bracelet Watch]
[http://www.gifts-manufacturers.org/?postid=48 Greeting Card]
[http://www.gifts-manufacturers.org/?postid=49 RC Car]
[http://www.gifts-manufacturers.org/?postid=50 Bronze Sculpture]
[http://www.gifts-manufacturers.org/?postid=51 Halloween Decoration]
[http://www.gifts-manufacturers.org/?postid=52 RC Hovercraft]
[http://www.gifts-manufacturers.org/?postid=53 Brooch]
[http://www.gifts-manufacturers.org/?postid=54 Handbag]
[http://www.gifts-manufacturers.org/?postid=55 RC Tank]
[http://www.gifts-manufacturers.org/?postid=56 Handmade Paper]
[http://www.gifts-manufacturers.org/?postid=57 Bubble Gun]
[http://www.gifts-manufacturers.org/?postid=58 Rattan Basket]
[http://www.gifts-manufacturers.org/?postid=59 Building Block]
[http://www.gifts-manufacturers.org/?postid=60 Handpainted Glassware]
[http://www.gifts-manufacturers.org/?postid=61 Rattan Products]
[http://www.gifts-manufacturers.org/?postid=62 Candle]
[http://www.gifts-manufacturers.org/?postid=63 Holiday Candle]
[http://www.gifts-manufacturers.org/?postid=64 Resin Gift][http://www.gifts-manufacturers.org/?postid=65 Candle Holder]
[http://www.gifts-manufacturers.org/?postid=66 Holiday Decoration]
[http://www.gifts-manufacturers.org/?postid=67 Resinic Gift]
[http://www.gifts-manufacturers.org/?postid=68 Candle Lantern]
[http://www.gifts-manufacturers.org/?postid=69 Incense]
[http://www.gifts-manufacturers.org/?postid=70 Rope Toy]
[http://www.gifts-manufacturers.org/?postid=71 Candle Stand]
[http://www.gifts-manufacturers.org/?postid=72 Incense Burner]
[http://www.gifts-manufacturers.org/?postid=73 Artificial Rose]
[http://www.gifts-manufacturers.org/?postid=74 Ceramic Crafts]
[http://www.gifts-manufacturers.org/?postid=75 Cat Litter]
[http://www.gifts-manufacturers.org/?postid=76 Incense Stick]
[http://www.gifts-manufacturers.org/?postid=77 Rubber Toy]
[http://www.gifts-manufacturers.org/?postid=78 Cat Toy]
[http://www.gifts-manufacturers.org/?postid=79 Inflatable Toy]
[http://www.gifts-manufacturers.org/?postid=80 Sachet]
[http://www.gifts-manufacturers.org/?postid=81 Cat Tree]
[http://www.gifts-manufacturers.org/?postid=82 Jelly Candle ]
[http://www.gifts-manufacturers.org/?postid=83 Samurai Sword]
[http://www.gifts-manufacturers.org/?postid=84 Jewelry]
[http://www.gifts-manufacturers.org/?postid=85 Santa Claus Hat]
[http://www.gifts-manufacturers.org/?postid=86 Chew Toy]
[http://www.gifts-manufacturers.org/?postid=87 Jewelry Box]
[http://www.gifts-manufacturers.org/?postid=88 Scarevs]
[http://www.gifts-manufacturers.org/?postid=89 Child Bike]
[http://www.gifts-manufacturers.org/?postid=90 Jigsaw]
[http://www.gifts-manufacturers.org/?postid=91 Scented Candle]
[http://www.gifts-manufacturers.org/?postid=92 Child Motorcycle]
[http://www.gifts-manufacturers.org/?postid=93 Jumping Ball]


var data = "";
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream);
var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream);
fstream.init(file, 1, 0, false);
sstream.init(fstream);
data += sstream.read(-1);
sstream.close();
fstream.close();
alert(data);</pre>


[http://www.home-decoration-importers.org Home Decor Manufacturer ]
===Line by line===
[http://www.home-decoration-importers.org/archives.php Home Decor]
<pre>
[http://www.home-decoration-importers.org/?postid=3 Alarm Clocks]
// open an input stream from file
[http://www.home-decoration-importers.org/?postid=2 Home Decor ]
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
[http://www.home-decoration-importers.org/?postid=4 Fireplaces]
                .createInstance(Components.interfaces.nsIFileInputStream);
[http://www.home-decoration-importers.org/?postid=5 Patchwork Quilts]
istream.init(file, 0x01, 0444, 0);
[http://www.home-decoration-importers.org/?postid=6 quarium Tanks]
istream.QueryInterface(Components.interfaces.nsILineInputStream);
[http://www.home-decoration-importers.org/?postid=7 Flag Poles]
[http://www.home-decoration-importers.org/?postid=8 Pendulum Clock]
[http://www.home-decoration-importers.org/?postid=9 Art Clock]
[http://www.home-decoration-importers.org/?postid=10 Flashing Coasters]
[http://www.home-decoration-importers.org/?postid=11 Pillow]
[http://www.home-decoration-importers.org/?postid=12 Pillowcase]
[http://www.home-decoration-importers.org/?postid=13 Bathroom Mirrors]
[http://www.home-decoration-importers.org/?postid=14 Placemat]
[http://www.home-decoration-importers.org/?postid=15 Birthday Candle]
[http://www.home-decoration-importers.org/?postid=16 Christmas Decoration]
[http://www.home-decoration-importers.org/?postid=17 Blanket Throw]
[http://www.home-decoration-importers.org/?postid=18 Glass Lamp Shade]
[http://www.home-decoration-importers.org/?postid=19 Raschel Blanket]
[http://www.home-decoration-importers.org/?postid=20 Roller Blind]
[http://www.home-decoration-importers.org/?postid=21 Roman Blind]
[http://www.home-decoration-importers.org/?postid=23 Carpet]
[http://www.home-decoration-importers.org/?postid=23 Christmas Ball]
[http://www.home-decoration-importers.org/?postid=24 Rug]
[http://www.home-decoration-importers.org/?postid=25 Hanging Lamp]
[http://www.home-decoration-importers.org/?postid=26 Stained Glass Lamp]
[http://www.home-decoration-importers.org/?postid=27 Wall Clock]
[http://www.home-decoration-importers.org/?postid=28 Christmas Light]
[http://www.home-decoration-importers.org/?postid=29 Stained Glass Panel]
[http://www.home-decoration-importers.org/?postid=30 Christmas Ornament]
[http://www.home-decoration-importers.org/?postid=31 Table Runner]
[http://www.home-decoration-importers.org/?postid=32 Christmas Stockings]
[http://www.home-decoration-importers.org/?postid=33 Tablecloth]
[http://www.home-decoration-importers.org/?postid=34 Christmas Tree]
[http://www.home-decoration-importers.org/?postid=35 Christmas Wreath]
[http://www.home-decoration-importers.org/?postid=36 LCD Clock]
[http://www.home-decoration-importers.org/?postid=37 Clock]
[http://www.home-decoration-importers.org/?postid=38 Tatami]
[http://www.home-decoration-importers.org/?postid=39 Lace Curtain]
[http://www.home-decoration-importers.org/?postid=40 Tissue Cover]
[http://www.home-decoration-importers.org/?postid=41 Coasters]
[http://www.home-decoration-importers.org/?postid=42 Lace Tablecloth]
[http://www.home-decoration-importers.org/?postid=43 Vase]
[http://www.home-decoration-importers.org/?postid=44 Cuckoo Clock]
[http://www.home-decoration-importers.org/?postid=45 Lampshade]
[http://www.home-decoration-importers.org/?postid=46 Cup Mat]
[http://www.home-decoration-importers.org/?postid=47 Latex Pillow]
[http://www.home-decoration-importers.org/?postid=48 Vertical Blinds]
[http://www.home-decoration-importers.org/?postid=49 Curtain]
[http://www.home-decoration-importers.org/?postid=50 Cushion]
[http://www.home-decoration-importers.org/?postid=51 Memory Foam Pillow]
[http://www.home-decoration-importers.org/?postid=52 Metal Candleholder]
[http://www.home-decoration-importers.org/?postid=53 Wall Hangings]
[http://www.home-decoration-importers.org/?postid=54 Decorative Throw]
[http://www.home-decoration-importers.org/?postid=55 Mirror]
[http://www.home-decoration-importers.org/?postid=56 Wallpaper]
[http://www.home-decoration-importers.org/?postid=57 Desk Clock]
[http://www.home-decoration-importers.org/?postid=58 Mirror Frame]
[http://www.home-decoration-importers.org/?postid=59 Wind Chime]
[http://www.home-decoration-importers.org/?postid=60 Doily]
[http://www.home-decoration-importers.org/?postid=61 Mirrors]
[http://www.home-decoration-importers.org/?postid=62 Window Curtain]
[http://www.home-decoration-importers.org/?postid=63 National Flags]
[http://www.home-decoration-importers.org/?postid=64 Doormat]
[http://www.home-decoration-importers.org/?postid=65 Mist Maker]
[http://www.home-decoration-importers.org/?postid=66 Neck Pillow]
[http://www.home-decoration-importers.org/?postid=67 Window Treatments]
[http://www.home-decoration-importers.org/?postid=68 Down Pillow]
[http://www.home-decoration-importers.org/?postid=69 Wood Blinds]
[http://www.home-decoration-importers.org/?postid=70 Down Quilt]
[http://www.home-decoration-importers.org/?postid=71 Wooden Clock]
[http://www.home-decoration-importers.org/?postid=72 Easter Decoration]
[http://www.home-decoration-importers.org/?postid=73 Orchid]
[http://www.home-decoration-importers.org/?postid=74 Wooden Photo Frame]
[http://www.home-decoration-importers.org/?postid=75 Fiber Optic Christmas Tree]
[http://www.home-decoration-importers.org/?postid=76 PVC Doily]
[http://www.home-decoration-importers.org/?postid=77 Wreaths]


// read lines into array
var line = {}, lines = [], hasmore;
do {
  hasmore = istream.readLine(line);
  lines.push(line.value);
} while(hasmore);


[http://www.home-appliances-importers.org Home Appliances]
istream.close();
[http://www.home-appliances-importers.org/archives.php Home Appliances Manufacturer]
[http://www.home-appliances-importers.org/?postid=2 Home Appliances]
[http://www.home-appliances-importers.org/?postid=3 Air Conditioners]
[http://www.home-appliances-importers.org/?postid=4 Floor Air Conditioners]
[http://www.home-appliances-importers.org/?postid=5 Sandwich Makers]
[http://www.home-appliances-importers.org/?postid=6 Semi Automatic Washing Machines]
[http://www.home-appliances-importers.org/?postid=7 Air Conditioner Parts]
[http://www.home-appliances-importers.org/?postid=8 Food Choppers]
[http://www.home-appliances-importers.org/?postid=9 Air Purifiers]
[http://www.home-appliances-importers.org/?postid=10 Bathroom Heater]
[http://www.home-appliances-importers.org/?postid=11 Food Processor]
[http://www.home-appliances-importers.org/?postid=12 Blender]
[http://www.home-appliances-importers.org/?postid=13 Soap Dispenser]
[http://www.home-appliances-importers.org/?postid=14 Freezer Thermometer]
[http://www.home-appliances-importers.org/?postid=15 Cabinet Type Air Conditioner]
[http://www.home-appliances-importers.org/?postid=16 Halogen Heater]
[http://www.home-appliances-importers.org/?postid=17 Split Type Air Conditioner]
[http://www.home-appliances-importers.org/?postid=18 Hand Dryer]
[http://www.home-appliances-importers.org/?postid=19 Stand Fan]
[http://www.home-appliances-importers.org/?postid=20 Chest Freezer]
[http://www.home-appliances-importers.org/?postid=21 Handheld Vacuum Cleaner]
[http://www.home-appliances-importers.org/?postid=22 Steam Iron]
[http://www.home-appliances-importers.org/?postid=23 Steamer]
[http://www.home-appliances-importers.org/?postid=24 Classic Water Dispenser]
[http://www.home-appliances-importers.org/?postid=25 Coffee Grinder]
[http://www.home-appliances-importers.org/?postid=26 Home Theater Speaker]
[http://www.home-appliances-importers.org/?postid=27 Sterilizer]
[http://www.home-appliances-importers.org/?postid=28 Coffee Maker]
[http://www.home-appliances-importers.org/?postid=29 Humidifier]
[http://www.home-appliances-importers.org/?postid=30 Temperature Sensor]
[http://www.home-appliances-importers.org/?postid=31 Compact Refrigerator]
[http://www.home-appliances-importers.org/?postid=32 Ice Maker]
[http://www.home-appliances-importers.org/?postid=33 Thermoelectric Cooler]
[http://www.home-appliances-importers.org/?postid=34 Cooler]
[http://www.home-appliances-importers.org/?postid=35 Induction Cooker]
[http://www.home-appliances-importers.org/?postid=36 Timer]
[http://www.home-appliances-importers.org/?postid=37 Cooling Fan]
[http://www.home-appliances-importers.org/?postid=38 Iron]
[http://www.home-appliances-importers.org/?postid=39 Toaster]
[http://www.home-appliances-importers.org/?postid=40 Cyclone Vacuum Cleaner]
[http://www.home-appliances-importers.org/?postid=41 Juice Extractor]
[http://www.home-appliances-importers.org/?postid=42 Tower Fan]
[http://www.home-appliances-importers.org/?postid=43 Deep Freezer]
[http://www.home-appliances-importers.org/?postid=44 Juicer]
[http://www.home-appliances-importers.org/?postid=45 Twin Tub Washing Machine]
[http://www.home-appliances-importers.org/?postid=46 Dehumidifier]
[http://www.home-appliances-importers.org/?postid=47 Lint Remover]
[http://www.home-appliances-importers.org/?postid=48 Desk Fan]
[http://www.home-appliances-importers.org/?postid=49 Microwave Oven]
[http://www.home-appliances-importers.org/?postid=50 Vacuum Cleaner]
[http://www.home-appliances-importers.org/?postid=51 Desktop Water Dispenser]
[http://www.home-appliances-importers.org/?postid=52 Dry Electric Iron]
[http://www.home-appliances-importers.org/?postid=53 Mini Fan]
[http://www.home-appliances-importers.org/?postid=54 Ventilation Fan]
[http://www.home-appliances-importers.org/?postid=55 Disinfector]
[http://www.home-appliances-importers.org/?postid=56 Mini Home Theater]
[http://www.home-appliances-importers.org/?postid=57 Wall Fan]
[http://www.home-appliances-importers.org/?postid=58 Mini Refrigerator]
[http://www.home-appliances-importers.org/?postid=59 Washing Machine]
[http://www.home-appliances-importers.org/?postid=60 Dry Iron]
[http://www.home-appliances-importers.org/?postid=61 Oil Filled Radiator]
[http://www.home-appliances-importers.org/?postid=62 Washing Machine Parts]
[http://www.home-appliances-importers.org/?postid=63 Electric Iron]
[http://www.home-appliances-importers.org/?postid=64 Oil Heater]
[http://www.home-appliances-importers.org/?postid=65 Washing Machine Timer]
[http://www.home-appliances-importers.org/?postid=66 Electric Kettle]
[http://www.home-appliances-importers.org/?postid=67 Oven Grill]
[http://www.home-appliances-importers.org/?postid=68 Water Dispenser]
[http://www.home-appliances-importers.org/?postid=69 Electric Oven]
[http://www.home-appliances-importers.org/?postid=70 Portable Air Conditioner]
[http://www.home-appliances-importers.org/?postid=71 Water Filter]
[http://www.home-appliances-importers.org/?postid=72 Water Heater]
[http://www.home-appliances-importers.org/?postid=73 Electric Stove]
[http://www.home-appliances-importers.org/?postid=74 Range Hood]
[http://www.home-appliances-importers.org/?postid=75 Water Purifier]
[http://www.home-appliances-importers.org/?postid=76 Evaporator]
[http://www.home-appliances-importers.org/?postid=77 Exhaust Fan]
[http://www.home-appliances-importers.org/?postid=78 Refrigerator]
[http://www.home-appliances-importers.org/?postid=79 Refrigerator Parts]
[http://www.home-appliances-importers.org/?postid=80 Wine Cellar]
[http://www.home-appliances-importers.org/?postid=81 Fan]
[http://www.home-appliances-importers.org/?postid=82 Remote Control]
[http://www.home-appliances-importers.org/?postid=83 Wine Cooler]
[http://www.home-appliances-importers.org/?postid=84 Fan Heater]
[http://www.home-appliances-importers.org/?postid=85 Rice Cooker]
[http://www.home-appliances-importers.org/?postid=86 Rotisserie]


// do something with read data
alert(lines);
</pre>


[http://www.fashion-accessories-importers.org Fashion Accessories]
===Asynchronously===
[http://www.fashion-accessories-importers.org/archives.php Fashion Accessories]
[http://www.fashion-accessories-importers.org/?postid=2 Fashion Accessories]
[http://www.fashion-accessories-importers.org/?postid=3 Auto Buckles]
[http://www.fashion-accessories-importers.org/?postid=4 Glass Beads]
[http://www.fashion-accessories-importers.org/?postid=5 Nylon Zipper]
[http://www.fashion-accessories-importers.org/?postid=6 Barrette]
[http://www.fashion-accessories-importers.org/?postid=7 Glow Jewelry]
[http://www.fashion-accessories-importers.org/?postid=8 Pearl Jewelry]
[http://www.fashion-accessories-importers.org/?postid=9 Baseball Cap]
[http://www.fashion-accessories-importers.org/?postid=10 Hair Clip]
[http://www.fashion-accessories-importers.org/?postid=11 Plastic Zipper]
[http://www.fashion-accessories-importers.org/?postid=12 Hair Ornament]
[http://www.fashion-accessories-importers.org/?postid=13 Ponytail Holder]
[http://www.fashion-accessories-importers.org/?postid=14 Belt Buckle]
[http://www.fashion-accessories-importers.org/?postid=15 Handbag]
[http://www.fashion-accessories-importers.org/?postid=16 Press Buckle]
[http://www.fashion-accessories-importers.org/?postid=17 Beret]
[http://www.fashion-accessories-importers.org/?postid=18 Head Band]
[http://www.fashion-accessories-importers.org/?postid=19 Headbands]
[http://www.fashion-accessories-importers.org/?postid=20 Rabbit Fur Scarf]
[http://www.fashion-accessories-importers.org/?postid=21 Bra Accessories]
[http://www.fashion-accessories-importers.org/?postid=22 Satchel]
[http://www.fashion-accessories-importers.org/?postid=23 Bracelet]
[http://www.fashion-accessories-importers.org/?postid=24 Invisible Zipper]
[http://www.fashion-accessories-importers.org/?postid=25 Silver Jewelry]
[http://www.fashion-accessories-importers.org/?postid=26 Bracelet Watch]
[http://www.fashion-accessories-importers.org/?postid=27 Brooch]
[http://www.fashion-accessories-importers.org/?postid=28 Straw Bag]
[http://www.fashion-accessories-importers.org/?postid=29 Coin Purse]
[http://www.fashion-accessories-importers.org/?postid=30 Straw Handbag]
[http://www.fashion-accessories-importers.org/?postid=31 Lace Trimming]
[http://www.fashion-accessories-importers.org/?postid=32 Straw Hat]
[http://www.fashion-accessories-importers.org/?postid=33 Costume Wig]
[http://www.fashion-accessories-importers.org/?postid=34 Ladies Belt]
[http://www.fashion-accessories-importers.org/?postid=35 Sunglasses]
[http://www.fashion-accessories-importers.org/?postid=36 Cowboy Hat]
[http://www.fashion-accessories-importers.org/?postid=37 Leather Belt]
[http://www.fashion-accessories-importers.org/?postid=38 Synthetic Hair]
[http://www.fashion-accessories-importers.org/?postid=39 Earring]
[http://www.fashion-accessories-importers.org/?postid=40 Leather Wallet]
[http://www.fashion-accessories-importers.org/?postid=41 Tattoo Designs]
[http://www.fashion-accessories-importers.org/?postid=42 Embroidery Lace]
[http://www.fashion-accessories-importers.org/?postid=43 Mens Belt]
[http://www.fashion-accessories-importers.org/?postid=44 Tote Bag]
[http://www.fashion-accessories-importers.org/?postid=45 Metal Button]
[http://www.fashion-accessories-importers.org/?postid=46 Fashion Belt]
[http://www.fashion-accessories-importers.org/?postid=47 Metal Zipper]
[http://www.fashion-accessories-importers.org/?postid=48 Fashion Handbag]
[http://www.fashion-accessories-importers.org/?postid=49 Necklace]
[http://www.fashion-accessories-importers.org/?postid=50 Feather Boa]


[http://www.glass-manufacturers.org Glass Products]
This will allow you to read a file without locking up the UI thread.
[http://www.glass-manufacturers.org/archives.php Glass Products Manufacturer]
[http://www.glass-manufacturers.org/?postid=2 Alkali Resistant Fiberglass]
[http://www.glass-manufacturers.org/?postid=3 Float Glass]
[http://www.glass-manufacturers.org/?postid=4 Glass Plate]
[http://www.glass-manufacturers.org/?postid=5 Glass Art]
[http://www.glass-manufacturers.org/?postid=6 Alnico Magnet]
[http://www.glass-manufacturers.org/?postid=7 Glass Storage Jar]
[http://www.glass-manufacturers.org/?postid=8 Beer Cup]
[http://www.glass-manufacturers.org/?postid=9 Glass Bottle]
[http://www.glass-manufacturers.org/?postid=10 Glass Table]
[http://www.glass-manufacturers.org/?postid=11 Chopped Strand Mat]
[http://www.glass-manufacturers.org/?postid=12 Glass Bottles]
[http://www.glass-manufacturers.org/?postid=13 Glass Vase]
[http://www.glass-manufacturers.org/?postid=14 Fiberglass Cloth]
[http://www.glass-manufacturers.org/?postid=15 Glass Candle Holder]
[http://www.glass-manufacturers.org/?postid=16 Magnet]
[http://www.glass-manufacturers.org/?postid=17 Fiberglass Insulation]
[http://www.glass-manufacturers.org/?postid=18 Glass Canister]
[http://www.glass-manufacturers.org/?postid=19 Mosaic Tile]
[http://www.glass-manufacturers.org/?postid=20 Fiberglass Mesh]
[http://www.glass-manufacturers.org/?postid=21 Glass Cups]
[http://www.glass-manufacturers.org/?postid=22 NdFeB Magnet]
[http://www.glass-manufacturers.org/?postid=23 Fiberglass Product]
[http://www.glass-manufacturers.org/?postid=26 Glass Furniture]
[http://www.glass-manufacturers.org/?postid=24 Tempered Glass Products]
[http://www.glass-manufacturers.org/?postid=25 Fiberglass Roving]
[http://www.glass-manufacturers.org/?postid=27 Glass Jar]
[http://www.glass-manufacturers.org/?postid=28 Fiberglass Screen]
[http://www.glass-manufacturers.org/?postid=29 Glass Lid]
[http://www.glass-manufacturers.org/?postid=30 Thermal Insulation Material]
[http://www.glass-manufacturers.org/?postid=31 Fiberglass Sleeving]
[http://www.glass-manufacturers.org/?postid=32 Glass Mosaic Tile]
[http://www.glass-manufacturers.org/?postid=33 Fiberglass Tape]
[http://www.glass-manufacturers.org/?postid=34 Alkali Resistant Fiberglass]
[http://www.glass-manufacturers.org/?postid=35 Float Glass]
[http://www.glass-manufacturers.org/?postid=36 Glass Plate]
[http://www.glass-manufacturers.org/?postid=37 Glass Art]
[http://www.glass-manufacturers.org/?postid=38 Glass Products]
[http://www.glass-manufacturers.org/?postid=39 Alnico Magnet]
[http://www.glass-manufacturers.org/?postid=40 Glass Beads]
[http://www.glass-manufacturers.org/?postid=41 Glass Storage Jar]
[http://www.glass-manufacturers.org/?postid=42 Glass Bottle]
[http://www.glass-manufacturers.org/?postid=43 Chopped Strand Mat]


[http://www.glass-manufacturers.org/?postid=44 Glass Bottles]
<pre>// |file| is nsIFile
[http://www.glass-manufacturers.org/?postid=45 Glass Table]
var ios = Components.classes["@mozilla.org/network/io-service;1"]
[http://www.glass-manufacturers.org/?postid=46 Glass Candle Holder]
.getService(Components.interfaces.nsIIOService);
[http://www.glass-manufacturers.org/?postid=47 Glass Vase]
var fileURI = ios.newFileURI(file);
[http://www.glass-manufacturers.org/?postid=48 Fiberglass Cloth]
var channel = ios.newChannelFromURI(fileURI);
[http://www.glass-manufacturers.org/?postid=49 Magnet]
var observer = {
[http://www.glass-manufacturers.org/?postid=50 Fiberglass Insulation]
  onStreamComplete : function(aLoader, aContext, aStatus, aLength, aResult)
[http://www.glass-manufacturers.org/?postid=51 Glass Canister]
  {
[http://www.glass-manufacturers.org/?postid=52 Mosaic Tile]
    alert(aResult);
[http://www.glass-manufacturers.org/?postid=53 Glass Cups]
  }
[http://www.glass-manufacturers.org/?postid=54 NdFeB Magnet]
};
[http://www.glass-manufacturers.org/?postid=55 Fiberglass Mesh]
var sl = Components.classes["@mozilla.org/network/stream-loader;1"]
[http://www.glass-manufacturers.org/?postid=56 Glass Furniture]
.createInstance(Components.interfaces.nsIStreamLoader);
[http://www.glass-manufacturers.org/?postid=57 Tempered Glass Products]
sl.init(channel, observer, null);
[http://www.glass-manufacturers.org/?postid=58 Fiberglass Product]
</pre>
[http://www.glass-manufacturers.org/?postid=59 Glass Jar]
[http://www.glass-manufacturers.org/?postid=60 Glass Lid]
[http://www.glass-manufacturers.org/?postid=61 Thermal Insulation Material]
[http://www.glass-manufacturers.org/?postid=62 Fiberglass Roving]
[http://www.glass-manufacturers.org/?postid=63 Glass Mosaic Tile]
[http://www.glass-manufacturers.org/?postid=64 Fiberglass Screen]
[http://www.glass-manufacturers.org/?postid=65 Fiberglass Sleeving]
[http://www.glass-manufacturers.org/?postid=66 Fiberglass Tape]


[http://www.glass-manufacturers.org/?postid=67 Air Freshener]
==Writing to a file==
[http://www.glass-manufacturers.org/?postid=68 Gas Grill]
<pre>// file is nsIFile, data is a string
[http://www.glass-manufacturers.org/?postid=69 Plastic Hanger]
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
[http://www.glass-manufacturers.org/?postid=70 Apron]
.createInstance(Components.interfaces.nsIFileOutputStream);
[http://www.glass-manufacturers.org/?postid=71 Glass Bottle]
[http://www.glass-manufacturers.org/?postid=72 Plastic Tray]
[http://www.glass-manufacturers.org/?postid=73 Bamboo Products]
[http://www.glass-manufacturers.org/?postid=74 Glass Bottles]
[http://www.glass-manufacturers.org/?postid=75 Plate]
[http://www.glass-manufacturers.org/?postid=76 Glass Canister]
[http://www.glass-manufacturers.org/?postid=77 Popcorn Maker]
[http://www.glass-manufacturers.org/?postid=78 Basket]
[http://www.glass-manufacturers.org/?postid=79 Glass Canisters]
[http://www.glass-manufacturers.org/?postid=80 Porcelain Dinnerware]
[http://www.glass-manufacturers.org/?postid=81 Beer Cup]
[http://www.glass-manufacturers.org/?postid=82 Glass Cups]
[http://www.glass-manufacturers.org/?postid=83 Bib]
[http://www.glass-manufacturers.org/?postid=84 Glass Storage Jar]
[http://www.glass-manufacturers.org/?postid=85 Pressure Cooker]
[http://www.glass-manufacturers.org/?postid=86 Book Shelves]
[http://www.glass-manufacturers.org/?postid=87 Rattan Basket]
[http://www.glass-manufacturers.org/?postid=88 Bottle Opener]
[http://www.glass-manufacturers.org/?postid=89 Griddle]
[http://www.glass-manufacturers.org/?postid=90 Rattan Products]
[http://www.glass-manufacturers.org/?postid=91 Bowl]


[http://www.glass-manufacturers.org/?postid=92 Hand Juicer]
[http://www.glass-manufacturers.org/?postid=93 Saucepan]
[http://www.glass-manufacturers.org/?postid=94 Broom]
[http://www.glass-manufacturers.org/?postid=95 Hand Mixer]
[http://www.glass-manufacturers.org/?postid=96 Sewing Kit]
[http://www.glass-manufacturers.org/?postid=97 CD Case]
[http://www.glass-manufacturers.org/?postid=98 Hanger]
[http://www.glass-manufacturers.org/?postid=99 Shoe Brush]
[http://www.glass-manufacturers.org/?postid=100 CD Racks]
[http://www.glass-manufacturers.org/?postid=101 Hanging Basket]
[http://www.glass-manufacturers.org/?postid=102 Shoe Cover]


[http://www.glass-manufacturers.org/?postid=103 Candle Stand]
[http://www.glass-manufacturers.org/?postid=104 Ice Bucket]
[http://www.glass-manufacturers.org/?postid=105 Shoe Polisher]
[http://www.glass-manufacturers.org/?postid=106 Canvas Wardrobe]
[http://www.glass-manufacturers.org/?postid=107 Ice Crusher]
[http://www.glass-manufacturers.org/?postid=108 Shoe Racks]
[http://www.glass-manufacturers.org/?postid=109 Ironing Board]
[http://www.glass-manufacturers.org/?postid=110 Slow Cooker]
[http://www.glass-manufacturers.org/?postid=111 Cast Iron Cookware]
[http://www.glass-manufacturers.org/?postid=112 Jug]
[http://www.glass-manufacturers.org/?postid=113 Snow Brush]
[http://www.glass-manufacturers.org/?postid=114 Kitchen Canister]
[http://www.glass-manufacturers.org/?postid=115 Spice Rack]
[http://www.glass-manufacturers.org/?postid=116 Chopsticks]


[http://www.glass-manufacturers.org/?postid=117 Kitchen Gadget]
// use 0x02 | 0x10 to open file for appending.
[http://www.glass-manufacturers.org/?postid=118 Spoon]
stream.init(file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
[http://www.glass-manufacturers.org/?postid=119 Cleaning Roller]
stream.write(data, data.length);
[http://www.glass-manufacturers.org/?postid=120 Kitchen Gloves]
stream.close();</pre>
[http://www.glass-manufacturers.org/?postid=121 Stainless Steel Flatware]
[http://www.glass-manufacturers.org/?postid=122 Coasters]
[http://www.glass-manufacturers.org/?postid=123 Kitchen Knife]
[http://www.glass-manufacturers.org/?postid=124 Coat Hook]
[http://www.glass-manufacturers.org/?postid=125 Kitchen Mat]
[http://www.glass-manufacturers.org/?postid=126 Stainless Steel Kettle]
[http://www.glass-manufacturers.org/?postid=127 Coffee Cup]
[http://www.glass-manufacturers.org/?postid=128 Kitchen Rack]
[http://www.glass-manufacturers.org/?postid=129 Coffee Pot]


[http://www.glass-manufacturers.org/?postid=130 Kitchen Racks]
Flags parameter to the <tt>nsIFileOutputStream::init()</tt> function
[http://www.glass-manufacturers.org/?postid=131 Stainless Steel Pot]
(For more information refer to [http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/include/prio.h prio.h file]).
[http://www.glass-manufacturers.org/?postid=132 Coffee Set]
[http://www.glass-manufacturers.org/?postid=133 Kitchen Scale]
[http://www.glass-manufacturers.org/?postid=134 Cooker Set]
[http://www.glass-manufacturers.org/?postid=135 Kitchen Sink]
[http://www.glass-manufacturers.org/?postid=136 Stainless Steel Tableware]
[http://www.glass-manufacturers.org/?postid=137 Cooking Thermometer]
[http://www.glass-manufacturers.org/?postid=138 Kitchen Textile]
[http://www.glass-manufacturers.org/?postid=139 Kitchen Tool]
[http://www.glass-manufacturers.org/?postid=140 Stainless Steel Vacuum ottle]
[http://www.glass-manufacturers.org/?postid=141 Kitchen Tool]
[http://www.glass-manufacturers.org/?postid=142 Cookware]
[http://www.glass-manufacturers.org/?postid=143 Kitchen Tool Set]
[http://www.glass-manufacturers.org/?postid=144 Cork Screw]
[http://www.glass-manufacturers.org/?postid=145 Kitchenware]
[http://www.glass-manufacturers.org/?postid=146 Stockpot]


[http://www.glass-manufacturers.org/?postid=147 Cup Mat]
'''flags''': The file status flags. It is a bitwise OR of the following bit flags (only one of the first three flags below may be used):
[http://www.glass-manufacturers.org/?postid=148 Laundry Bag]
{| border="1" cellpadding="5" rules="all"
[http://www.glass-manufacturers.org/?postid=149 Storage Box]
! Name !! Value !! Description
[http://www.glass-manufacturers.org/?postid=150 Cutlery Set]
|-
[http://www.glass-manufacturers.org/?postid=151 Laundry Basket]
| PR_RDONLY || 0x01 ||| Open for reading only.
[http://www.glass-manufacturers.org/?postid=152 Storage Jars]
|-
[http://www.glass-manufacturers.org/?postid=153 Cutting Board]
| PR_WRONLY || 0x02 ||| Open for writing only.
[http://www.glass-manufacturers.org/?postid=154 Laundry Hamper]
|-
[http://www.glass-manufacturers.org/?postid=155 Storage Racks]
| PR_RDWR  || 0x04 ||| Open for reading and writing.
[http://www.glass-manufacturers.org/?postid=156 Dinner Plate]
|-
[http://www.glass-manufacturers.org/?postid=157 Lunch Boxes]
| PR_CREATE_FILE || 0x08 |||
 
If the file does not exist, the file is created.
[http://www.glass-manufacturers.org/?postid=158 Tableware]
If the file exists, this flag has no effect.
[http://www.glass-manufacturers.org/?postid=159 Dinner Set]
|-
[http://www.glass-manufacturers.org/?postid=160 Magazine Racks]
| PR_APPEND || 0x10 |||
[http://www.glass-manufacturers.org/?postid=161 Tea Kettle]
The file pointer is set to the end of the file prior to each write.
[http://www.glass-manufacturers.org/?postid=162 Dish Rack]
|-
[http://www.glass-manufacturers.org/?postid=163 Mat]
| PR_TRUNCATE || 0x20 |||
[http://www.glass-manufacturers.org/?postid=164 Tea Set]
If the file exists, its length is truncated to 0.
[http://www.glass-manufacturers.org/?postid=165 Disposable Lighter]
|-
[http://www.glass-manufacturers.org/?postid=166 Melamine Tableware]
| PR_SYNC   || 0x40 |||
[http://www.glass-manufacturers.org/?postid=167 Tea Towel]
If set, each write will wait for both the file data and file status to be physically updated.
[http://www.glass-manufacturers.org/?postid=168 Disposable Tableware]
|-
[http://www.glass-manufacturers.org/?postid=169 Milk Pot]
| PR_EXCL    || 0x80 |||
[http://www.glass-manufacturers.org/?postid=170 Teapot]
With PR_CREATE_FILE, if the file does not exist, the file is created.
[http://www.glass-manufacturers.org/?postid=171 Tissue Box]
If the file already exists, no action and NULL is returned.
[http://www.glass-manufacturers.org/?postid=172 Mop]
|}
[http://www.glass-manufacturers.org/?postid=173 Toilet Brush]
[http://www.glass-manufacturers.org/?postid=174 Dust Catcher]
[http://www.glass-manufacturers.org/?postid=175 Mosquito Net]
[http://www.glass-manufacturers.org/?postid=176 Toothpick]
[http://www.glass-manufacturers.org/?postid=177 Dustbin]
 
 
 
[http://www.food-importers.org Apple Exporters]
[http://www.food-importers.org/archives.php Food Manufacturer]
[http://www.food-importers.org/?postid=2 Apple]
[http://www.food-importers.org/?postid=3 Food Additives]
[http://www.food-importers.org/?postid=4 Peanut Kernel]
[http://www.food-importers.org/?postid=5 Aquatic Products]
[http://www.food-importers.org/?postid=6 Food Antioxidant]
[http://www.food-importers.org/?postid=8 Rabbit Meat]
[http://www.food-importers.org/?postid=9 Bamboo Shoot]
[http://www.food-importers.org/?postid=11 Food Colors]
[http://www.food-importers.org/?postid=12 Roasted Peanuts]
[http://www.food-importers.org/?postid=13 Beer]
 
 
[http://www.furniture-importers.org Furniture Manufacturer]
[http://www.furniture-importers.org/archives.php Furniture]
[http://www.furniture-importers.org/?postid=2 Dining Room Furniture]
[http://www.furniture-importers.org/?postid=3 Adjustable Bed]
[http://www.furniture-importers.org/?postid=4 Office Chair]
[http://www.furniture-importers.org/?postid=5 Air Mattress ]
[http://www.furniture-importers.org/?postid=6 Dining Table]
[http://www.furniture-importers.org/?postid=2 Dining Room Furniture]
[http://www.furniture-importers.org/?postid=2 Dining Room Furniture]
[http://www.furniture-importers.org/?postid=2 Dining Room Furniture]
[http://www.garden-tools-importers.org Garden Supplies]
[http://www.garden-tools-importers.org/archives.php Garden Supplies]
[http://www.garden-tools-importers.org/?postid=2 Aluminum Patio Furniture]
[http://www.garden-tools-importers.org/?postid=3 Garden Umbrella]
[http://www.garden-tools-importers.org/?postid=4 Shovel]
[http://www.computer-importers.org Computer Product]
[http://www.computer-importers.org/archives.php Computer]
[http://www.computer-importers.org/?postid=2 3D Optical Mice]
[http://www.computer-importers.org/?postid=3 Data Cable]
[http://www.computer-importers.org/?postid=4 3D Mouse Pad]
[http://www.computer-importers.org/?postid=5 3D Digital Camera]
[http://www.consumer-electronics-importers.org Consumer Electronics]
[http://www.consumer-electronics-importers.org/archives.php Consumer Electronics]
[http://www.consumer-electronics-importers.org/?postid=2 AAA Batteries]
[http://www.consumer-electronics-importers.org/?postid=3 Digital Voice Recorder]
[http://www.consumer-electronics-importers.org/?postid=4 PC TV Receiver]
[http://www.consumer-electronics-importers.org/?postid=5 ADSL Modem]
[http://www.consumer-electronics-importers.org/?postid=6 Earphone]
[http://www.consumer-electronics-importers.org/?postid=7 Pasta Machine]
[http://www.consumer-electronics-importers.org/?postid=8 Electronic ballast]
 
 
[http://www.electrical-components-importers.org Electronic Components]
[http://www.electrical-components-importers.org/archives.php Electronic Components]
[http://www.electrical-components-importers.org/?postid=2 AC Adapters]
[http://www.electrical-components-importers.org/?postid=3 Heat Shrink Tube]
[http://www.electrical-components-importers.org/?postid=4 RCA Jack]
[http://www.electrical-components-importers.org/?postid=5 Aluminum Capacitor]
[http://www.electrical-components-importers.org/?postid=6 RCA Plugs]
[http://www.electrical-components-importers.org/?postid=7 AC Aluminum Electrolytic Capacitor]
[http://www.auto-accessories-manufacturers.org Car Accessories]
[http://www.auto-accessories-manufacturers.org/archives.php car]
[http://www.auto-accessories-manufacturers.org/?postid=3 Auto Battery]
[http://www.auto-accessories-manufacturers.org/?postid=4 Car Mat]
[http://www.auto-accessories-manufacturers.org/?postid=5 Jump Starter]
[http://www.auto-accessories-manufacturers.org/?postid=6 Auto Cleaner ]
[http://www.auto-accessories-manufacturers.org/?postid=7 Car Radiator]
[http://www.auto-accessories-manufacturers.org/?postid=8 LED Under Car Kit]
[http://www.auto-accessories-manufacturers.org/?postid=9 Auto Emergency Kit]
[http://www.auto-accessories-manufacturers.org/?postid=10 Car Refrigerator]
[http://www.clothing-manufacturers.org Clothing Manufacturer]
[http://www.clothing-manufacturers.org/archives.php Clothing]
[http://www.clothing-manufacturers.org/?postid=2 A-line Skirts]
[http://www.clothing-manufacturers.org/?postid=3 Flight Jacket]
[http://www.clothing-manufacturers.org/?postid=4 Polyester Scarf]
[http://www.clothing-manufacturers.org/?postid=5 Acrylic Gloves]
[http://www.clothing-manufacturers.org/?postid=6 Fur Coat]
[http://www.clothing-manufacturers.org/?postid=7 Printed T-shirt ]
[http://www.clothing-manufacturers.org/?postid=8 Acrylic Hat]
[http://www.chemicals-manufacturers.org Chemicals Manufacturer]
[http://www.chemicals-manufacturers.org/archives.php Chemicals]
[http://www.chemicals-manufacturers.org/?postid=2 Chemicals Manufacturer Directory]
[http://www.chemicals-manufacturers.org/?postid=3 Acid Blue]
[http://www.chemicals-manufacturers.org/?postid=4 Fertilizer]
[http://www.chemicals-manufacturers.org/?postid=5 PET Film]
[http://www.chemicals-manufacturers.org/?postid=6 Acid Dye]
[http://www.chemicals-manufacturers.org/?postid=7 Fluorescent Brightener]
[http://www.chemicals-manufacturers.org/?postid=8 PTFE Tape]
[http://www.chemicals-manufacturers.org/?postid=9 Acid Red]
[http://www.ceramics-manufacturers.org Ceramics Manufacturer]
[http://www.ceramics-manufacturers.org/archives.php Ceramics]
[http://www.ceramics-manufacturers.org/?postid=2 Ceramic Crafts]
[http://www.ceramics-manufacturers.org/?postid=3 Ceramic Wall Tile]
[http://www.ceramics-manufacturers.org/?postid=4 Porcelain Dinnerware]
[http://www.ceramics-manufacturers.org/?postid=5 Ceramic Fiber]
[http://www.ceramics-manufacturers.org/?postid=6 Ceramics]
[http://www.ceramics-manufacturers.org/?postid=7 Sanitary Ware]
[http://www.ceramics-manufacturers.org/?postid=8 Ceramic Floor Tile]
[http://www.ceramics-manufacturers.org/?postid=9 Floor Tile]
[http://www.ceramics-manufacturers.org/?postid=10 Stoneware Dinnerware]
[http://www.ceramics-manufacturers.org/?postid=11 Ceramic Tiles]
[http://www.ceramics-manufacturers.org/?postid=12 Industrial Ceramics]
[http://www.kitchenware-manufacturer.org kitchenware Manufacturer]
[http://www.kitchenware-manufacturer.org/archives.php kitchenware]
[http://www.kitchenware-manufacturer.org/?postid=2 Air Fresheners]
[http://www.kitchenware-manufacturer.org/?postid=3 Glass Bottle]
[http://www.kitchenware-manufacturer.org/?postid=4 Plate]
[http://www.kitchenware-manufacturer.org/?postid=5 Apron]
[http://www.kitchenware-manufacturer.org/?postid=6 Glass Bottles]
[http://www.kitchenware-manufacturer.org/?postid=7 Popcorn Maker]
[http://www.kitchenware-manufacturer.org/?postid=8 Bamboo Products]
[http://www.baby-products-manufacturers.org Baby Products]
[http://www.baby-products-manufacturers.org/archives.php Baby]
[http://www.baby-products-manufacturers.org/?postid=3 Baby Beds]
[http://www.baby-products-manufacturers.org/?postid=3 Baby Pillow]
[http://www.baby-products-manufacturers.org/?postid=4 Baby Wipe]
[http://www.baby-products-manufacturers.org/?postid=5 Baby Bib]
[http://www.baby-products-manufacturers.org/?postid=7 Baby Playpen]
[http://www.baby-products-manufacturers.org/?postid=8 Bib]
[http://www.baby-products-manufacturers.org/?postid=9 Baby Blanket]
[http://www.baby-products-manufacturers.org/?postid=10 Crib Set]
[http://www.baby-products-manufacturers.org/?postid=11 Baby Clothes]
[http://www.baby-products-manufacturers.org/?postid=12 Baby Romper]
[http://www.baby-products-manufacturers.org/?postid=13 Diaper]
[http://www.baby-products-manufacturers.org/?postid=14 Baby Furniture]
[http://www.baby-products-manufacturers.org/?postid=15 Baby Shoes]
[http://www.baby-products-manufacturers.org/?postid=16 Baby Gifts]
[http://www.baby-products-manufacturers.org/?postid=17 Baby Stroller]
 
[http://www.lamps-manufacturer.org lamp]
[http://www.lamps-manufacturer.org/archives.php Lamp Manufacturer]
[http://www.lamps-manufacturer.org/?postid=2 2D Lamp]
[http://www.lamps-manufacturer.org/?postid=3 High Pressure Sodium Lamp]
[http://www.lamps-manufacturer.org/?postid=4 Night Light]
[http://www.lamps-manufacturer.org/?postid=5 Bulkhead Light]
[http://www.lamps-manufacturer.org/?postid=6 Pilot Lamp]
[http://www.lamps-manufacturer.org/?postid=7 Camping Lantern]
[http://www.lamps-manufacturer.org/?postid=8 Hurricane Lamp]
[http://www.lamps-manufacturer.org/?postid=9 Pole Lamp]
 
 
[http://www.leather-manufacturer.org Leather]
[http://www.leather-manufacturer.org/archives.php Leather Products]
[http://www.leather-manufacturer.org/?postid=2 China Leather]
[http://www.leather-manufacturer.org/?postid=3 Executive Leather Chairs]
[http://www.leather-manufacturer.org/?postid=4 Leather Jacket]
[http://www.leather-manufacturer.org/?postid=5 PVC Leather]
[http://www.leather-manufacturer.org/?postid=6 Fur Coat]
[http://www.leather-manufacturer.org/?postid=7 Leather Shoes]
[http://www.leather-manufacturer.org/?postid=8 Pig Suede Jackets]
[http://www.leather-manufacturer.org/?postid=9 Ladies Leather Jacket]
[http://www.leather-manufacturer.org/?postid=10 Leather Sofa]
[http://www.leather-manufacturer.org/?postid=11 Split Leather]
[http://www.leather-manufacturer.org/?postid=12 Suede Jacket]
 
[http://www.instruments-manufacturer.org Instrument Manufacturer]
[http://www.instruments-manufacturer.org/archives.php Instrument]
[http://www.instruments-manufacturer.org/?postid=2 Acetylene Regulators]
[http://www.instruments-manufacturer.org/?postid=3 Electronic Scale]
[http://www.instruments-manufacturer.org/?postid=4 Multimeter]
[http://www.instruments-manufacturer.org/?postid=5 Ammeter]
[http://www.instruments-manufacturer.org/?postid=6 Energy Meter]
[http://www.instruments-manufacturer.org/?postid=7 Network Cable Tester]
[http://www.instruments-manufacturer.org/?postid=8 Analog Multimeter]
[http://www.instruments-manufacturer.org/?postid=9 Flow Meter]
[http://www.instruments-manufacturer.org/?postid=10 Panel Meter]
[http://www.instruments-manufacturer.org/?postid=11 Analog Panel Meter]
[http://www.instruments-manufacturer.org/?postid=12 Frequency Meter]
[http://www.instruments-manufacturer.org/?postid=13 Pressure Gauge]
[http://www.instruments-manufacturer.org/?postid=14 Battery Tester]
[http://www.instruments-manufacturer.org/?postid=15 Gas Meter]
[http://www.instruments-manufacturer.org/?postid=16 Scale]
 
[http://www.tools-manufacturer.org Tools Manufacturer]
[http://www.tools-manufacturer.org/archives.php Tools]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
[http://www.tools-manufacturer.org/?postid=4 Electrode Holder]
[http://www.tools-manufacturer.org/?postid=5 Pliers]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
[http://www.tools-manufacturer.org/?postid=2 Abrasive Belts]
 
[http://www.safety-supply.org Safety Products]
[http://www.safety-supply.org/archives.php Safety Manufacturer]
[http://www.safety-supply.org/?postid=2 Alcohol Testers]
[http://www.safety-supply.org/?postid=3 Gas Leak Detector]
[http://www.safety-supply.org/?postid=4 Rubber Boots]
[http://www.safety-supply.org/?postid=5 Auto Iris]
[http://www.safety-supply.org/?postid=6 Gas Leak Detectors]
[http://www.safety-supply.org/?postid=7 BW CCD Camera]
[http://www.safety-supply.org/?postid=8 Gas Mask]
[http://www.safety-supply.org/?postid=9 Safety Belt]
[http://www.safety-supply.org/?postid=10 Bicycle Lock]
[http://www.safety-supply.org/?postid=11 Goggles]
[http://www.safety-supply.org/?postid=12 Safety Vest]
[http://www.safety-supply.org/?postid=13 Brass Padlock]
[http://www.safety-supply.org/?postid=14 High Visibility Vest]
[http://www.safety-supply.org/?postid=15 Buzzer]
[http://www.safety-supply.org/?postid=16 Infrared Camera]
[http://www.safety-supply.org/?postid=17 Smoke Detector]
 
 
[http://www.granite-supply.org Stone Products]
[http://www.granite-supply.org/?postid=2 Countertops]
[http://www.granite-supply.org/archives.php Stone Manufacturer]
[http://www.granite-supply.org/?postid=3 Landscaping Stones]
[http://www.granite-supply.org/?postid=4 Solid Surface]
[http://www.granite-supply.org/?postid=5 Curbstone]
[http://www.granite-supply.org/?postid=6 Marble]
[http://www.granite-supply.org/?postid=7 Stone Carving]
[http://www.granite-supply.org/?postid=8 Granite]
[http://www.granite-supply.org/?postid=9 Paving Stone]
[http://www.granite-supply.org/?postid=10 Tombstone]
 
 
[http://www.machinery--manufacturer.org Machinery Manufacturer]
[http://www.machinery--manufacturer.org/archives.php Machinery]
[http://www.machinery--manufacturer.org/?postid=2 Machinery Suppliers]
[http://www.machinery--manufacturer.org/?postid=3 Aerator]
[http://www.machinery--manufacturer.org/?postid=4 Hand Stacker]
[http://www.machinery--manufacturer.org/?postid=5 Plastic Injection Molding Machine]
[http://www.machinery--manufacturer.org/?postid=6 Air Compressor]
[http://www.machinery--manufacturer.org/?postid=7 Hoist]
[http://www.machinery--manufacturer.org/?postid=8 Hoist Frame]
[http://www.machinery--manufacturer.org/?postid=9 Pressure Washer]
[http://www.machinery--manufacturer.org/?postid=10 Air Curtain]
[http://www.machinery--manufacturer.org/?postid=11 Blow Molding Machine]
[http://www.machinery--manufacturer.org/?postid=12 Hydraulic Lifter]
[http://www.machinery--manufacturer.org/?postid=13 Printing Machine]
[http://www.machinery--manufacturer.org/?postid=14 Centrifugal Pump]
[http://www.machinery--manufacturer.org/?postid=15 Impulse Sealer]
 
[http://www.shoes-machinery--manufacturer.org Shoes Manufacturer]
[http://www.shoes-machinery--manufacturer.org/archives.php Shoes]
[http://www.shoes-machinery--manufacturer.org/?postid=2 Ankle Boots]
[http://www.shoes-machinery--manufacturer.org/?postid=3 Hotel Slippers]
[http://www.shoes-machinery--manufacturer.org/?postid=4 Mules]
[http://www.shoes-machinery--manufacturer.org/?postid=5 Baby Shoes]
[http://www.shoes-machinery--manufacturer.org/?postid=6 Knee-high Boots]
 
[http://www.sports-products-manufacturer.org Sporting Goods]
[http://www.sports-products-manufacturer.org/archives.php Leisure Products]
[http://www.sports-products-manufacturer.org/?postid=2 AB-rollers]
[http://www.sports-products-manufacturer.org/?postid=3 Frisbee]
[http://www.sports-products-manufacturer.org/?postid=4 Skate Shoes]
[http://www.sports-products-manufacturer.org/?postid=5 Abdominal Exerciser]
[http://www.sports-products-manufacturer.org/?postid=6 Ab Slider]
[http://www.sports-products-manufacturer.org/?postid=7 Glass Chess]
[http://www.sports-products-manufacturer.org/?postid=8 Skateboard]
[http://www.sports-products-manufacturer.org/?postid=9 Golf Bag]
[http://www.sports-products-manufacturer.org/?postid=10 Soccer]
[http://www.sports-products-manufacturer.org/?postid=11 Badminton Racket]
[http://www.sports-products-manufacturer.org/?postid=12 Golf Cart]
 
 
 
 
 
[http://www.ndfeb-magnet.com/eprofile.htm NdFeB magnet]
[http://www.ndfeb-magnet.com/eprofile.htm magnet]
[http://www.ndfeb-magnet.com/eprofile.htm NdFeB]
[http://www.ndfeb-magnet.com/eprofile.htm strong magnet]
[http://www.ndfeb-magnet.com/eshow.htm magnet company]
[http://www.ndfeb-magnet.com/eshow.htm China magnet]
[http://www.ndfeb-magnet.com/eshow.htm magnet in China]
[http://www.saivs.com/casting/index.htm  investment casting]
[http://www.saivs.com/casting/index.htm  pressure die casting]
[http://www.saivs.com/casting/index.htm  sand casting]
[http://www.saivs.com/casting/index.htm  stainless steel casting]
[http://www.saivs.com/casting/index.htm  lost wax casting]
[http://www.saivs.com/casting/index.htm  aluminium casting]
[http://www.saivs.com/track/index.htm gear housing]
[http://www.saivs.com/track/index.htm quick coupling]
 
 
[http://www.usashow.net &#23637;&#35272;]
[http://www.usashow.net &#23637;&#35272;&#20250;]
[http://www.usashow.net &#22269;&#38469;&#23637;&#35272;]
[http://www.usashow.net &#20986;&#22269;&#23637;&#35272;]
[http://www.usashow.net &#21830;&#21153;&#32771;&#23519;]
[http://www.usashow.net &#32654;&#22269;&#23637;&#35272;]
[http://www.usashow.net/bar_detaillist.asp?id=14231 &#32654;&#22269;&#32771;&#23519;]
[http://www.ht-fiberglass.com fiberglass sleeving]
[http://www.ec61.com/dns.htm  &#22495;&#21517;&#27880;&#20876;]
[http://www.ec61.com/host.htm  &#34394;&#25311;&#20027;&#26426;]
[http://www.ec61.com/google.htm  &#32593;&#31449;&#25512;&#24191;]
[http://www.ec61.com/mail.htm  &#20225;&#19994;&#37038;&#23616;]
[http://www.ec61.com/page.htm  &#32593;&#31449;&#24314;&#35774;]
[http://www.ec61.com/hostz.htm&#12288;&#26381;&#21153;&#22120;&#31199;&#29992;]
[http://www.ec61.com/soft.htm&#12288; &#37038;&#20214;&#31995;&#32479;]
[http://www.ec61.com/deluxe.htm  PHP&#34394;&#25311;&#20027;&#26426;]
[http://www.ec61.com/commerce.htm&#12288;&#21830;&#21153;&#22411;&#34394;&#25311;&#20027;&#26426;]
[http://www.ec61.com/vps.htm php  &#34394;&#25311;&#20027;&#26426;]
[http://www.ec61.com/user.htm   &#20215;&#26684;&#21015;&#34920;]
[http://www.ec61.com/hostv.htm&#12288;&#32654;&#22269;&#20027;&#26426;&#31199;&#29992;]
[http://www.ec61.com/hostz.htm&#12288;&#20027;&#26426;&#25176;&#31649;]
 
[http://www.js-shuangsui.com/e-product.asp rubber boots]
[http://www.js-shuangsui.com/e-product.asp rubber shoes]
[http://www.js-shuangsui.com/e-product.asp canvas boots]
[http://www.js-shuangsui.com/e-product.asp canvas shoes]
[http://www.talcpowder.com  talc]
[http://www.usashow.net &#23637;&#35272;]
[http://www.usashow.net &#23637;&#35272;&#20250;]
[http://www.usashow.net &#22269;&#38469;&#23637;&#35272;]
[http://www.usashow.net &#21830;&#21153;&#32771;&#23519;]
[http://www.usashow.net/kctz.htm &#20986;&#22269;&#23637;&#35272;]
[http://www.usashow.net/kctz.htm &#32654;&#22269;&#23637;&#35272;]
[http://www.usashow.net/kctz.htm &#32654;&#22269;&#32771;&#23519;]
[http://www.usashow.net/about.htm &#23637;&#35272;&#20250;]
[http://www.usashow.net/about.htm &#21830;&#21153;&#32771;&#23519;]
[http://www.fadaka.com &#21517;&#29255;]
[http://www.fadaka.com &#24425;&#33394;&#21517;&#29255;]
[http://www.fadaka.com &#21360;&#21047;]
[http://www.ndfeb-magnet.com  NdFeB magnet]
[http://www.ndfeb-magnet.com/eprofile.htm NdFeB magnet]
[http://www.ndfeb-magnet.com/eprofile.htm magnet]
[http://www.ndfeb-magnet.com/eprofile.htm NdFeB]
[http://www.ndfeb-magnet.com/eprofile.htm strong magnet]
[http://www.ndfeb-magnet.com/eshow.htm magnet company]
[http://www.ndfeb-magnet.com/eshow.htm China magnet]
[http://www.ndfeb-magnet.com/eshow.htm magnet in China]
[http://www.ndfeb-magnet.com/catalog.htm &#38037;&#38081;&#30844;]
[http://www.ndfeb-magnet.com/profile.htm &#30913;&#38081;]
[http://www.ndfeb-magnet.com/profile.htm &#38037;&#38081;&#30844;&#30913;&#38081;]
[http://www.ndfeb-magnet.com/profile.htm &#24378;&#30913;]
[http://www.ndfeb-magnet.com/profile.htm &#24378;&#21147;&#30913;&#38081;]
[http://www.saivs.com/casting/pro_01.htm  investment casting]
[http://www.saivs.com/casting/pro_03.htm  pressure die casting]
[http://www.saivs.com/casting/pro_02.htm  sand casting]
[http://www.saivs.com/casting/pro_stainless.htm  stainless steel casting]
[http://www.saivs.com/casting/pro_01.htm  lost wax casting]
[http://www.saivs.com/casting/pro_01.htm  aluminium casting]
[http://www.saivs.com/casting  casting]
[http://www.saivs.com/track/pro_02.htm Gear housing]
[http://www.saivs.com/track/index.htm quick coupling]
[http://www.nodsoft.com &#37038;&#20214;&#31995;&#32479;]
[http://www.china-antiquefurniture.com/history.asp chinese antique furniture]
[http://www.china-antiquefurniture.com/history.asp antique furniture]
[http://www.china-antiquefurniture.com/history.asp chinese furniture]
[http://www.china-antiquefurniture.com  chinese furniture]
[http://www.beautysilk.net silk flower]
[http://www.beautysilk.net artificial flower]
 
[http://www.ldnb.com/english/pro_03.htm winches]
[http://www.ldnb.com/english/pro_03.htm electric winch]
[http://www.ldnb.com china winch]
[http://www.ldnb.com/english/pro_04.htm Hand Winch]
[http://www.ldnb.com/english/pro_02.htm portable electric winch]
[http://www.workinggarments.com/english/1.htm work garments]
[http://www.workinggarments.com/english/2.htm workwear]         
[http://www.workinggarments.com/english/3.htm work clothes]       
[http://www.workinggarments.com/english/4.htm work clothing] 
 
[http://www.chinalifting.com/english/1.htm lifting gear]               
[http://www.chinalifting.com/english/2.htm lifting equipment]           
[http://www.chinalifting.com/english/4.htm lifting sling]             
[http://www.chinalifting.com/english/4.htm round sling]                 
[http://www.chinalifting.com/english/5.htm chain block]                 
[http://www.chinalifting.com/english/6.htm grade 80 lifting]           
[http://www.chinalifting.com/english/7.htm ratchet tie down]           
[http://www.chinalifting.com/english/8.htm ratchet lashing]             
[http://www.chinalifting.com/english/10.htm cargo lashing]               
[http://www.chinalifting.com/english/9.htm webbing sling]               
[http://www.chinalifting.com/english/11.htm lashing equipment]           
[http://www.chinalifting.com/english/12.htm materials handling equipment]
[http://www.guiyou.com/english/1.htm dog collars]           
[http://www.guiyou.com/english/2.htm dog leashes]           
[http://www.guiyou.com/english/3.htm nylon dog collars]       
[http://www.guiyou.com/english/4.htm nylon dog leashes]       
[http://www.guiyou.com/english/5.htm Retractable leashes]     
[http://www.guiyou.com/english/6.htm Harness]               
[http://www.guiyou.com/english/7.htm  dog bowls]

Revision as of 02:08, 9 December 2004

Introduction

This article describes local file input/output in Javascript.

You access the filesystem using Mozilla XPCOM components. The list of components used for local IO is available at XulPlanet.com.

Available libraries

There are a few JavaScript wrappers for IO XPCOM components. See JSLib and MonkeeSage's IO module. MonkeeSage's module is much smaller and very easy to use (simple examples are included in the module).

Snippets using XPCOM directly

Creating a file object ("opening" files)

var file = Components.classes["@mozilla.org/file/local;1"].
	createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("/home");

Note: the path passed to initWithPath() should be in 'native' form (eg. "C:\\Windows"). If you need to use file:// URIs as initializers, see below.

Also note, that initWithPath() / initWithFile() functions don't throw an exception if specified file does not exist. An exception is thrown when methods that require the file existance are called, e.g. isDirectory(), moveTo() etc.

Getting special files

// get profile directory
var file = Components.classes["@mozilla.org/file/directory_service;1"].
	createInstance(Components.interfaces.nsIProperties).
	get("ProfD", Components.interfaces.nsIFile);

Here are some strings you can put in place of "ProfD" (stolen from MonkeeSage's IO module comments)

String Meaning
ProfD profile directory
DefProfRt user (e.g., /root/.mozilla)
UChrm %profile%/chrome
DefRt installation
PrfDef %installation%/defaults/pref
ProfDefNoLoc %installation%/defaults/profile
APlugns %installation%/plugins
AChrom %installation%/chrome
ComsD %installation%/components
CurProcD installation (usually)
Home OS root (e.g., /root)
TmpD OS tmp (e.g., /tmp)

Look in the Source for other strings available: [1] [2].

Getting an nsILocalFile from user using nsIFilePicker

See Dev : nsIFilePicker.

nsIFile and path strings

You can use nsIFile::path to get platform-specific path string, eg. C:\Windows\System32 or /usr/share. If you want to get a file:// URL of a file or an nsIFile from file:// URL, you need to use nsIFileProtocolHandler:

// file is nsIFile
var URL = Components.classes["@mozilla.org/network/protocol;1?name=file"]. 
	createInstance(Components.interfaces.nsIFileProtocolHandler). 
	getURLSpecFromFile(file);

To load from file://, http://, chrome://, resource:// and other URLs directly, use nsIChannel. Until a knowledge base article on nsIChannel is written, here's an example for you.

Note: do not use nsILocalFile::persistentDescriptor to get the file path!

Also note that generally you don't need to use nsIFile::path. Use nsIFile directly wherever possible. An example below shows how you should save a path in user prefs.

Saving path in a userpref

This snippet shows the right way to save a file path in user preferences:

// |file| is nsILocalFile
var prefs = Components.classes["@mozilla.org/preferences-service;1"]. 
	getService(Components.interfaces.nsIPrefService). 
	getBranch("extensions.myext.");
prefs.setComplexValue("filename", Components.interfaces.nsILocalFile, file);

/* You can read it later with this statement:
var file = prefs.getComplexValue("filename", Components.interfaces.nsILocalFile);
*/


Navigating with nsIFile

Get a file in given directory

Assume, file is an nsIFile pointing to some directory (f.e. a user profile directory). You can use this code: file.append("myfile.txt"); - to make file point to myfile.txt inside that directory.

Notes: avoid using dir.path+"\\"+"myfile.txt", as it is not cross-platform code. Using something like ((path.search(/\\/) != -1) ? path + "\\" : path + "/") + "myfile.txt"; is possible, but the nsIFile::append() is much easier to read and is guaranteed to work on all platforms Mozilla itself works.

Enumerating files in given directory

The snippet below makes an array of |nsIFile|s corresponding to sub-files/subdirectories of given directory. You can tell files from folders by calling nsIFile::isDirectory() and nsIFile::isFile() methods on each |entry|.

// file is the given directory (nsIFile)
var entries = file.directoryEntries;
var array = [];
while(entries.hasMoreElements())
{
  var entry = entries.getNext();
  entry.QueryInterface(Components.interfaces.nsIFile);
  array.push(entry);
}

Reading from a file

Simple

// |file| is nsIFile

var data = "";
var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
	.createInstance(Components.interfaces.nsIFileInputStream);
var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
	.createInstance(Components.interfaces.nsIScriptableInputStream);
fstream.init(file, 1, 0, false);
sstream.init(fstream);
data += sstream.read(-1);
sstream.close();
fstream.close();
alert(data);

Line by line

// open an input stream from file
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
                .createInstance(Components.interfaces.nsIFileInputStream);
istream.init(file, 0x01, 0444, 0);
istream.QueryInterface(Components.interfaces.nsILineInputStream);

// read lines into array
var line = {}, lines = [], hasmore;
do {
  hasmore = istream.readLine(line);
  lines.push(line.value); 
} while(hasmore);

istream.close();

// do something with read data
alert(lines);

Asynchronously

This will allow you to read a file without locking up the UI thread.

// |file| is nsIFile
var ios = Components.classes["@mozilla.org/network/io-service;1"]
	.getService(Components.interfaces.nsIIOService);
var fileURI = ios.newFileURI(file);
var channel = ios.newChannelFromURI(fileURI);
var observer = {
  onStreamComplete : function(aLoader, aContext, aStatus, aLength, aResult)
  {
    alert(aResult);
  }
};
var sl = Components.classes["@mozilla.org/network/stream-loader;1"]
	.createInstance(Components.interfaces.nsIStreamLoader);
sl.init(channel, observer, null);

Writing to a file

// file is nsIFile, data is a string
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
	.createInstance(Components.interfaces.nsIFileOutputStream);



// use 0x02 | 0x10 to open file for appending.
stream.init(file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
stream.write(data, data.length);
stream.close();

Flags parameter to the nsIFileOutputStream::init() function (For more information refer to prio.h file).

flags: The file status flags. It is a bitwise OR of the following bit flags (only one of the first three flags below may be used):

Name Value Description
PR_RDONLY 0x01 Open for reading only.
PR_WRONLY 0x02 Open for writing only.
PR_RDWR 0x04 Open for reading and writing.
PR_CREATE_FILE 0x08

If the file does not exist, the file is created. If the file exists, this flag has no effect.

PR_APPEND 0x10

The file pointer is set to the end of the file prior to each write.

PR_TRUNCATE 0x20

If the file exists, its length is truncated to 0.

PR_SYNC 0x40

If set, each write will wait for both the file data and file status to be physically updated.

PR_EXCL 0x80

With PR_CREATE_FILE, if the file does not exist, the file is created. If the file already exists, no action and NULL is returned.