• Post Reply Bookmark Topic Watch Topic
  • New Topic

how long this file need to read it??  RSS feed

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all....
i want to read a file using java I/O...but i want to guess how long this file need to finish reading ..
can i do that??
regards
 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be able to give an aprox. value if you know the
size of the file and the time it takes to read a char/line.

The size, i.e. number of bytes, of the file can easily be retrived (see File API).

The time it takes to read a byte can only be an aproximation (please correct
me if I am wrong) since there's alot of other things going on that takes
CPU time and reads/writes to the harddisk.

/Svend Rost
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java designers have spent a lot of time on getting IO as close to the operating system maximum as possible. Alot depends on how the data gets treated, reading the whole file into a byte[] at one go is fast, reading the file as characters one by one or one line at a time is much slower.

Here is a link to Sun's tutorial on IO.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!