Summary

As you have seen in this chapter, it is possible to substantially improve serial reading and writing. Random file accesses are inefficient in comparison to serial access because the drive has to do a lot of seeking. In addition, buffering techniques do not pay off as much for random access. In fact, most games use resource files to pack many files together to reduce the overhead of locating, opening, and closing files. Some games even go as far as ordering the data in a resource file to match the order in which the files must be loaded in an attempt to reduce the load time. This is particularly important when data has to be read from a CD-ROM or DVD.

In this chapter, we have looked at the more important classes of the java.io and java.nio packages and seen how to use them. Perhaps the most important thing to take away from this chapter is the knowledge of what happens behind the scenes when IO, and particularly file IO, are performed. In addition, understanding of buffers and how they can be used to improve the performance of your game is important. Also, when it comes to performance, never make any assumptions about the performance of a task. Even if you find documentation that suggests certain results, if you need optimal performance, you have to find out for yourself. Much of the documentation that comes with JDK has to be generic and cannot provide VM-specific details. Keep in mind that changes to a version of VM, VMs implemented by different vendors, API changes, the underlying OS, and the hardware being used can result in significant performance changes.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net