Java Tutorial

 
 
 
 
import java.io.*;

class  RandRW
{
    public static void main(String[] args) 
    {
         RandomAccessFile file = null;
         try{
             file = new RandomAccessFile(\"rand.txt\",\"rw\");

             //Writing to the file
             file.writeChar(\'V\');
             file.writeInt(999);
             file.writeDouble(99.99);

             file.seek(0);     //Go to the begining
             //Reading from the file
             System.out.println(file.readChar());
             System.out.println(file.readInt());
             System.out.println(file.readDouble());

             file.seek(2);  //Go to the Second Item
             System.out.println(file.readInt());

             //Go to the end and append false to the file
             file.seek(file.length());
             file.writeBoolean(true);

             file.seek(4);
             System.out.println(file.readBoolean());
             file.close();
            }catch(Exception e) {}
        }
}

    Related Post:
  1. Program to display bank account

  2. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  3. An applet program to draw circle in center of the canvas

  4. An applet program to draw concentric circle in center of the canvas

  5. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

  6. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  7. Program to reverse the number eg given no : - 12345, output want :- 54321

  8. Program of an applet to display alternate filled and empty circle

  9. File handling program to copy characters from one file to another

  10. Program which simulate the dictionary in java

  11. An applet program to find maximum of three numbers using textField

  12. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

  13. An applet program to display alternate filled and empty circle that to in row and column format

  14. An applet of displaying simple moving banner

  15. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

  16. Program to show an example of searching Strings for subStrings

  17. An applet program to perform quick sort

  18. Add,delete,Update in LISTS

  19. GUI application in java, which enter the details of a student and on the submit display the details of the student

  20. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

 
 
Didn't find what you were looking for? Find more on Program that reads and writes random access file