Java Blog

 
 
 
import java.io.*;

class  ReadWritePrimitive
{
    public static void main(String[] args) 
    {
           try{
                FileOutputStream fos = new FileOutputStream(\"data.txt\");
                DataOutputStream dos = new DataOutputStream(fos);

                //Writing primitive data to the data.txt file
                dos.writeInt(2000);
                dos.writeDouble(888.88);
                dos.writeChar(\'V\');
                dos.writeBoolean(false);
                fos.close();
                dos.close();

               //Reading primitive data to the data.txt file
               FileInputStream fis = new FileInputStream(\"data.txt\");
               DataInputStream dis = new DataInputStream(fis);
               System.out.println(dis.readInt());
               System.out.println(dis.readDouble());
               System.out.println(dis.readChar());
               System.out.println(dis.readBoolean());
               fis.close();
               dis.close();
             }catch(Exception e) {}

    }
}

    Related Post:
  1. 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

  2. Program of UDP news server

  3. Program to display following things on the client machine a)date and time of the server machine b)date and time of the client machine and difference

  4. An applet program that displays Text at the center of the string which is passed as parameter

  5. An applet of displaying simple moving banner

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

  7. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  8. An applet program of passing parameters

  9. Write a program for restaurant

  10. Program to show an example of getting at characters in a String

  11. An applet program showing Clicked Event on canvas

  12. An applet program to give demo of getDocumentBase() and getCodeBase() methods

  13. Program that reads and writes random access file

  14. Program to show the use of some Character Methods

  15. An applet program to display moving banner

  16. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  17. 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

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

  19. Program to show the use of Bitwise Operator (&) AND

  20. Program of inventory management and demonstrating interactive input and output

 
 
Didn't find what you were looking for? Find more on Program of reading and writing primitive data