Posted By

robslegtenhorst on 04/15/11


Tagged

file search replace AIR as3


Versions (?)

AS3 AIR file search and replace


 / Published in: ActionScript
 

  1. // search through each file
  2. for each (var $file : File in _dataArray)
  3. {
  4. if (_fs != null) _fs.close();
  5.  
  6. _fs = new FileStream();
  7.  
  8. // read the file content
  9. _fs.open($file, FileMode.READ);
  10. var data : String = _fs.readUTFBytes(_fs.bytesAvailable);
  11. _fs.close();
  12.  
  13. // replace the current content with the new
  14. _fs = new FileStream();
  15. _fs.open($file, FileMode.WRITE);
  16.  
  17. data = data.split($searchString).join($replaceString);
  18.  
  19. _fs.writeUTFBytes(data);
  20. _fs.close();
  21. }

Report this snippet  

You need to login to post a comment.