Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 9 of 9
E:\classes\com\javaworld\jpitfalls\article5>java com.javaworld.jpitfalls.article5.GoodFileRename dummy2.txt exists. path: E:\classes\com\javaworld\jpitfalls\article5 new name: E:\classes\com\javaworld\jpitfalls\article5\dummy2.tst Rename to new extension Successful. Delete Successful.
Thus, you shouldn't use the File class as if it represents a file instead of the filename. With that in mind, once the file is renamed, operations such as
delete() work only on the new filename.
In summary, gaining familiarity in Java programming is key to avoiding Java pitfalls. We fixed the traps presented in this
article by simply learning the proper functions of certain classes. First, remember to position and size components when adding
them to a layer in a JLayeredPane. Second, remember that enumerating over a Vector does not work in conjunction with the remove() operation, as Iterator does. Finally, do not use the File class for operations after a successful renameTo().
I would like to thank everyone who emailed me about this column over the past year. The feedback and support has been wonderful. This column has been a rewarding experience, and I will return after a break.
Until then ... best wishes.