hi, My Ruby code is as follows In a class One method creats and writes (write_data) one/more files by reading data from another file. Another method reads (read_data) these files and perform some action. Observed that I am not able to read contents of files just created (though I can see data in those files as expected) when I call these functions one after the other. Where as if I run only the 'Read' method I am able to read the files. There seems to be no error in the code, but I feel that since the file is just getting created it is not allowing me to do any action on that unless my program is closed and a new program started. Is there any solution for this? Attached the code for your view. Naresh
on 2009-02-27 13:56
on 2009-02-27 14:17
Try calling File#flush method after writing to the newly created file, so that the buffered data is flushed to OS. Or you can even call File#fsync to ensure that the data is actually written to disk.
on 2009-02-27 17:39
If these tricks don't do, try closing the writing filehandle before opening the reading one, that does it for me. L-P 2009/2/27 Choi, Junegunn <email@example.com>
on 2009-03-03 09:26
Louis-Philippe wrote: > If these tricks don't do, try closing the writing filehandle before > opening > the reading one, that does it for me. > It did work for me too, thanks you very much. Naresh