Java NIO (New IO) was introduced in JDK 1.4. While Java IO centralizes around Stream/Reader/Writer and uses decorator pattern as its main design, where you have decorate one InputStream type with each other in the right order. The NIO uses Channel/Buffer/Selector.
Read a file using IO
File file =new File("C:\\test\\test.txt");
FileInputStream fis = new FileInputStream(file);
//decorate BufferedReader with InputStreamReader
BufferedReader d = new BufferedReader(new InputStreamReader(fis));
String line=null;
while((line = d.readLine()) != null){
System.out.println(line);
}
Read a file using NIO
RandomAccessFile rFile = new RandomAccessFile("C:\\test\\test.txt", "rw");
//get Channel
FileChannel inChannel = rFile.getChannel();
//Intialize byte buffer
ByteBuffer buf = ByteBuffer.allocate(100);
//read data to buffer
while(inChannel.read(buf)>0){
buf.flip(); //flip into read mode
while(buf.hasRemaining()){
System.out.print((char)buf.get());
}
buf.clear();
}
rFile.close();
Great Article
ReplyDeleteJava Online Course | Java EE Training
Java Training Institutes in Chennai | java j2ee training institutes in chennai | Java Training in Chennai | J2EE Training in Chennai | Java Course in Chennai
Java Interview Questions | Java Training Institutes | IT Technical Articles
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteJava Training in Chennai Core Java Training in Chennai Core Java Training in Chennai
Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai
ReplyDeleteA befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
ReplyDeleteOracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
This is really a wonderful post. First, I would rather thank the stress of golf but the connection plays a leading role in the accommodation. Fantastic stuff.
ReplyDeleteDedicatedHosting4u.com
ReplyDeleteشركة تنظيف فلل براس الخيمة
شركة تنظيف سجاد براس الخيمة
شركة تنظيف كنب براس الخيمة
شركة مكافحة الرمة براس الخيمة
شركة مكافحة الصراصير براس الخيمة
شركة مكافحة حشرات براس الخيمة
شركة تنظيف مطابخ براس الخيمه
شركة تنظيف منازل براس الخيمه
ReplyDeleteشركة تنظيف موكيت براس الخيمه
شركة تنظيف خزانات براس الخيمه
شركة تنظيف واجهات زجاجية براس الخيمه
شركة جلي رخام براس الخيمه
It should be noted that whilst ordering papers for sale at paper writing service, you can get unkind attitude. In case you feel that the bureau is trying to cheat you, don't buy term paper from it. r&b musica italian
ReplyDeleteYour Affiliate Money Making Machine is ready -
ReplyDeletePlus, making money online using it is as simple as 1 . 2 . 3!
Here's how it works...
STEP 1. Choose affiliate products the system will promote
STEP 2. Add PUSH BUTTON TRAFFIC (it LITERALLY takes JUST 2 minutes)
STEP 3. See how the affiliate products system explode your list and sell your affiliate products all on it's own!
Are you ready??
Click here to launch the system
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeletedigital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil
Thanks for Sharing - ( Groarz branding solutions )
Great Post, Thanks for sharing the great post such a wonderful information.
ReplyDeleteJava Online Training
Java Online Training In Chennai
Core Java Online Training
Great, thanks for sharing this post.Much thanks again. Awesome.
ReplyDeletedata science course in hyderabad
data science training in hyderabad
This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.
ReplyDeleteibm full form in india |
ssb ka full form |
what is the full form of dp |
full form of brics |
gnm nursing full form |
full form of bce |
full form of php |
bhim full form |
nota full form in india |
apec full form