posted 12 years ago
In most cases it's as Joe says. On big exception is - if you want to copy bytes to or from a file - use FileChannel's transferFrom() or transferTo() methods. They are faster (typically) and easier to use than doing the same thing with streams. Which is unusual - typically the NIO stuff is harder to use, and only sometimes is noticably faster. (But sometimes it's a lot faster, so it may be worth investigating.) Note that if you're reading from a file using JDK 5.0 (cough), you can often use a Scanner to get the best of both worlds - fast NIO access combined with ease of use.