digitalmars.D.learn - Reading a file using stream.
- Carlos Madureira (11/11) Jan 18 2006 I was looking at the code in samples/d2html.d and it doesn't use it but ...
- Ben Hinkle (5/19) Jan 18 2006 use a std.stream.BufferedFile or a std.cstream.CFile (which is buffered ...
- Hasan Aljudy (2/30) Jan 19 2006 "is" is a keyword! Cannot be used as an identifier.
- Ben Hinkle (4/32) Jan 19 2006 hehe. good point. I totally missed that one. Plus I spelled "note" as "n...
I was looking at the code in samples/d2html.d and it doesn't use it but waits for a exception to get out of the while loop. I want to read a file in chunks, but the exception doesn't seem like a good mechanism to exit the while loop and the implementation of eof() for files seems slow since it uses seeking. InputStream is = File("test.txt"); while (is.eof()) { is.read(buffer); .. }
Jan 18 2006
"Carlos Madureira" <Carlos_member pathlink.com> wrote in message news:dqm5gc$193c$1 digitaldaemon.com...I was looking at the code in samples/d2html.d and it doesn't use it but waits for a exception to get out of the while loop. I want to read a file in chunks, but the exception doesn't seem like a good mechanism to exit the while loop and the implementation of eof() for files seems slow since it uses seeking. InputStream is = File("test.txt"); while (is.eof()) { is.read(buffer); .. }use a std.stream.BufferedFile or a std.cstream.CFile (which is buffered by the C runtime). Unbuffered file i/o will be slow. Also not I think you want while (!is.eof()).
Jan 18 2006
Ben Hinkle wrote:"Carlos Madureira" <Carlos_member pathlink.com> wrote in message news:dqm5gc$193c$1 digitaldaemon.com..."is" is a keyword! Cannot be used as an identifier.I was looking at the code in samples/d2html.d and it doesn't use it but waits for a exception to get out of the while loop. I want to read a file in chunks, but the exception doesn't seem like a good mechanism to exit the while loop and the implementation of eof() for files seems slow since it uses seeking. InputStream is = File("test.txt"); while (is.eof()) { is.read(buffer); .. }use a std.stream.BufferedFile or a std.cstream.CFile (which is buffered by the C runtime). Unbuffered file i/o will be slow. Also not I think you want while (!is.eof()).
Jan 19 2006
"Hasan Aljudy" <hasan.aljudy gmail.com> wrote in message news:dqpmaa$1896$1 digitaldaemon.com...Ben Hinkle wrote:hehe. good point. I totally missed that one. Plus I spelled "note" as "not". :-P"Carlos Madureira" <Carlos_member pathlink.com> wrote in message news:dqm5gc$193c$1 digitaldaemon.com..."is" is a keyword! Cannot be used as an identifier.I was looking at the code in samples/d2html.d and it doesn't use it but waits for a exception to get out of the while loop. I want to read a file in chunks, but the exception doesn't seem like a good mechanism to exit the while loop and the implementation of eof() for files seems slow since it uses seeking. InputStream is = File("test.txt"); while (is.eof()) { is.read(buffer); .. }use a std.stream.BufferedFile or a std.cstream.CFile (which is buffered by the C runtime). Unbuffered file i/o will be slow. Also not I think you want while (!is.eof()).
Jan 19 2006