• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Himai Minh

I/O vs NIO

Ranch Hand
Posts: 658
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am reading I/O and NIO from last 10 days, yet it is confusing to me. don't know why i am still confuse. actually i am not getting that ,where i am, what i have learned and what i have to learn next.
some questions i my mind..
1. why NIO was invented
2. according to IO NIO tutorial on doc.oracle, they have performed almost every operation by using Files class in java.nio.file package . is that true that Files class alone have all the capabilities performed by java.io package.
3. which option is better for use, IO or NIO ?
Java Cowboy
Posts: 16084
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You were explicitly mentioning java.nio.file: The original API for working with files and file systems (class java.io.File) was lacking features that people needed, for example for working with file attributes (whether file are read-only etc.), symbolic links, and watching file systems for changes. Those new features and many more were added with the interfaces and classes in the java.nio.file package.

My opinion is: if you're writing new code, try to use the NIO API for files instead of the old API. This starts at using java.nio.file.Path instead of java.io.File.

Besides new APIs for working with files and file systems, the java.nio package contains much more. The most important part of it are interfaces and classes that make it possible to do asynchronous and non-blocking I/O, which is necessary for creating high-performance and scalable server systems in Java.

Programming with asynchronous and non-blocking I/O is a lot harder than using plain old simple synchronous, blocking I/O, and you don't need to make your program asynchronous and non-blocking unless there's a specific need to do so.
I don't like that guy. The tiny ad agrees with me.
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic