Mega Code Archive

 
Categories / Ruby / File Directory
 

Get char and unget char

f = File.open("data", "r:binary") # Open data file for binary reads c = f.getc                        # Read the first byte as an integer f.ungetc(c)                       # Push that byte back c = f.readchar                    # Read it back again