rubyÎļþ²Ù×÷
1¡¢ÎļþµÄ´ò¿ªÓë¹Ø±Õ
``r'' Read-only, starts at beginning of file (default mode).
``r+'' Read-write, starts at beginning of file.
``w'' Write-only, truncates existing file to zero length or creates a new file for writing.
``w+'' Read-write, truncates existing file to zero length or creates a new file for reading and writing.
``a'' Write-only, starts at end of file if file exists, otherwise creates a new file for writing.
``a+'' Read-write, starts at end of file if file exists, otherwise creates a new file for reading and writing.
``b'' (DOS/Windows only) Binary file mode (may appear with any of the key letters listed above).
ʹÓÃfile.new·½·¨»ñȡһ¸öÎļþ¾ä±úÀ´¶ÔÎļþ²Ù×÷£¬²Ù×÷½áÊøºófile.closeÀ´¹Ø±ÕÎļþ¡£
file.open·½·¨ÊÇnew·½·¨µÄÀ©³ä£¬¸Ã·½·¨¿ÉÓдúÂë¿é£¬¸Ã´úÂë¿é½áÊøºó×Ô¶¯close£¬¶øÇÒÔÚ²Ù×÷¹ý³ÌÖз¢Éú´íÎóʱÄܹ»×Ô¶¯ÊÕ¼¯´íÎó²¢ÍƳö
Èç
file.open("filepath") do |file|
file.each do |line| ... end
end
һЩÎļþµÄ³£ÓÃÃüÁ
File.open(dir+"/read.txt","w") do |file|
file.puts("djkjsadlkjdkdsfdsee")
end puts File.exists?(dir+"/read.txt") ÎļþÊÇ·ñ´æÔÚ
puts File.directory?(dir+"/read.txt") ÎļþÊÇ·ñÊÇĿ¼·¾¶
puts File.file?(dir+"/read.txt") ÊÇ·ñÊÇÎļþ
puts File.zero?(dir+"/read.txt") ÎļþÄÚÈݳ¤¶ÈÊÇ·ñΪ0
puts File.size(dir+"/read.txt") »ñÈ¡Îļþ´óС
put
Ïà¹ØÎĵµ£º
Ruby on Rails 2.2.3 + Mysql 5.0 ½â¾öGBK±àÂëÎÊÌâ
1¡¢ruby1.8.6+raile2.2.3+(Mysql 5.0 GBK±àÂë) £»
2¡¢¹¤³ÌÉèÖÃ
¹¤³ÌĿ¼\app\controllers\appliction.rb
#¼ÓÈëÒÔÏ´úÂ룬λÖÃËæ±ã
be ......
Ó¢ÎÄ×ÊÔ´£º
http://www.ruby-lang.org/
http://www.ruby-doc.org£¨·ÃÎʲ»µ½¿ÉÓÃÏÂÃæµÄÍøÖ··ÃÎÊ£©£º
http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.ruby-doc.org
http://rubyforge.org/
http://www.ruby-forum.org/bb
http://www.rubygarden.org/ruby
http://www.rubyxml.com/
http://www.pragmaticprogra ......
1£ºFXRuby is a library for developing powerful and sophisticated cross-platform graphical user interfaces (GUIs) for your Ruby applications. It¡¯s based on the FOX Toolkit, a popular open source C++ library developed by Jeroen van der Zijp. What that means for you as an application developer is that ......
×î½üÒ»¶Îʱ¼ä£¬ÔÚæºõ£ò£õ£â£ùµÄ²âÊÔ¿ò¼Ü¡£
´Ó²»ÊìϤBDD,RSpecµ½Ä¿Ç°Äܹ»ÉÔ΢×öµã¶«Î÷£¬¸Ð¾õ·Ç³£²»´í¡£
RubyÊÇÃŷdz£Áé»îµÄ½Å±¾ÓïÑÔ£¬´Ó¶øÒ²×ÔÈ»ÏëÓÃËü×÷Ϊ²âÊԽű¾¡£ÈÃÎÒÃDZàдµÄ´úÂë½øÈë£Ô£Ä£ÄµÄģʽ¡£
µ±È»£Ô£Ä£Ä¾¹ýÕâЩÄêµÄ·¢Õ¹£¬ÏÖÔÚÒѾ½øÈëBDD(Behaviour-Driven Develop)µÄʱ´ú¡£
BDDºÍTDDÖ÷ÒªµÄ× ......
def delVss(path)
if File.directory?(path)
for f in d = Dir.open(path)
fpath = File.join(path, f)
if(f!="."&&f!="..")
......