STDOUT.reopen(File.open("./OUTPUT",'w+'))
现在我需要再次将STDOUT路由到终端.
我该怎么办?
orig_std_out = STDOUT.clone STDOUT.reopen(File.open('OUTPUT','w+')) puts "test to file" STDOUT.reopen(orig_std_out) puts "test to screen"