def write_bom(fp) data = " " data.setbyte(0, 0xEF) data.setbyte(1, 0xBB) data.setbyte(2, 0xBF) fp.write(data) end
FileUtils.rm("d:/temp/foo.txt")
FileUtils.rm(Dir.glob("d:/temp/*.jpg"))
require File.expand_path('../../a.rb', __FILE__)
require 'pathname' path = Pathname.new("/tmp") path += 'sample.txt' #結合できる。戻り値はPathnameオブジェクト p path # => #<Pathname:/tmp/sample.txt>
f = File.open("log.txt", "w") f.print("abc\r\n") f.close
abc^M