Mega Code Archive

 
Categories / Ruby / File Directory
 

Use the method sysread to read the contents of a file

file3 = File.new("C:\\Ruby\\Sample"," r") file3.sysread(20) # This statement will output the first 20 characters of the file.  # The file pointer will now be placed at the 21st character in the file.