Return to Snippet

Revision: 44615
at April 15, 2011 00:09 by robslegtenhorst


Updated Code
// search through each file
for each (var $file : File in _dataArray)
{
	if (_fs != null) _fs.close();

	_fs = new FileStream();

	// read the file content
	_fs.open($file, FileMode.READ);
	var data : String = _fs.readUTFBytes(_fs.bytesAvailable);
	_fs.close();

	// replace the current content with the new
	_fs = new FileStream();
	_fs.open($file, FileMode.WRITE);
		
	data = data.split($searchString).join($replaceString);

	_fs.writeUTFBytes(data);
	_fs.close();
}

Revision: 44614
at April 15, 2011 00:09 by robslegtenhorst


Initial Code
for each (var $file : File in _dataArray)
{
	if (_fs != null) _fs.close();

	_fs = new FileStream();

	// read the file content
	_fs.open($file, FileMode.READ);
	var data : String = _fs.readUTFBytes(_fs.bytesAvailable);
	_fs.close();

	// replace the current content with the new
	_fs = new FileStream();
	_fs.open($file, FileMode.WRITE);
		
	data = data.split($searchString).join($replaceString);

	_fs.writeUTFBytes(data);
	_fs.close();
}

Initial URL


Initial Description


Initial Title
AS3 AIR file search and replace

Initial Tags
file, search, replace

Initial Language
ActionScript