本文简要介绍ruby语言中  File.new  的用法。
用法
new(filename, mode="r" [, opt]) → filenew(filename [, mode [, perm]] [, opt]) → file根据给定的mode打开以filename命名的文件并返回一个新的 File 对象。
有关 mode 和 opt 的说明,请参见  IO.new 。
如果正在创建文件,则可以在 perm 中给出权限位。这些模式和权限位取决于平台;在 Unix 系统上,有关详细信息,请参阅 open(2) 和 chmod(2) 手册页。
新的  File  对象是缓冲模式(或非同步模式),除非 filename 是 tty。有关同步模式,请参见  IO#flush  、  IO#fsync  、  IO#fdatasync  和  IO#sync=  。
例子
f = File.new("testfile", "r")
f = File.new("newfile",  "w+")
f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)相关用法
- Ruby File.identical?用法及代码示例
- Ruby File.dirname用法及代码示例
- Ruby File.directory?用法及代码示例
- Ruby File.link用法及代码示例
- Ruby File.expand_path用法及代码示例
- Ruby File.lstat用法及代码示例
- Ruby File.umask用法及代码示例
- Ruby File.absolute_path?用法及代码示例
- Ruby File.rename用法及代码示例
- Ruby File.split用法及代码示例
- Ruby File.chmod用法及代码示例
- Ruby File.atime用法及代码示例
- Ruby File.to_path用法及代码示例
- Ruby File.stat用法及代码示例
- Ruby File.chown用法及代码示例
- Ruby File.path用法及代码示例
- Ruby File.absolute_path用法及代码示例
- Ruby File.mtime用法及代码示例
- Ruby File.fnmatch用法及代码示例
- Ruby File.build用法及代码示例
- Ruby File.ftype用法及代码示例
- Ruby File.join用法及代码示例
- Ruby File.readlink用法及代码示例
- Ruby File.world_writable?用法及代码示例
- Ruby File.ctime用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 File.new。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
