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. An applet program to find maximum of three numbers using textField

  2. Program to sort the contents of an array using Bubble Sort

  3. Add,delete,Update in LISTS

  4. CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL

  5. Program of date server and client

  6. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

  7. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  8. Program that will read real number from the keyboard and print the following output in one line: small Integer not less The Given Number Largest Int

  9. Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.

  10. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  11. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  12. An applet program to display text

  13. Program to show the use of operator (>>) Shift Right, propagating the sign bit from the left

  14. Socket program of multi client chat server

  15. Program to show the use of Logical AND Operator (&) in If Statements

  16. Program which will read a string and rewrite it in the alphabetical order

  17. Program to show the comparing of Strings for equality

  18. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

  19. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  20. Program of binary search tree

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