You are here:   HomeJava ProgrammingStreamRandom File Handling in Java Example
by Dinesh Thakur Category: Stream

 

import java.lang.System;

import java.io.RandomAccessFile;
import java.io.IOException;
public class RandomFileHandling
{
       public static void main(String args[])throws IOException
      {
           RandomAccessFile fp = new RandomAccessFile("ecomputernotes.bat","rw");
           fp.writeBoolean(true);
           fp.writeInt(50);
           fp.writeChar('r');
           fp.writeDouble(1234.56);
           fp.seek(5);
           System.out.println(fp.readChar());                       
           System.out.println(fp.readDouble());                   
           fp.seek(0);
           System.out.println(fp.readBoolean());                  
           System.out.println(fp.readInt());                        
           fp.close();
      }
                                                                                     
}

Random File Handling





Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article