• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Any Performance Optimization Tips for using NIO

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I read that Java1.4.x has got java.nio packages which provides better performance when compared to the old IO Packages.

Can any one tell me which existing classes of IO Can be replaed with the classes in NIO packages !!

Thanks
Sateesh
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The java.io classes actually use the NIO classes behind the scenes, so there's no replacement to be done. Unless, of course, you need the NIO-specific functionality like non-blocking IO or file locking.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic