Java Tutorial

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

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

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

  4. Program of date server and client

  5. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  6. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  7. Program to show an example of Copying i.e. Clonning Objects

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

  9. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  10. Simple Applet which will show life cycle of an Applet

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

  12. Program to show the use of Nested Loops

  13. Program to show an example of Calling a Base Class Method from a Derived Class

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

  15. Program in CORBA which takes a long sentence from the client (at least 7 words), passes to the server, server separates out each word

  16. Program to read the table elements into a two-dimensional array temperature

  17. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

  18. Corba program of Count Client Applet, IDL,Server, Client

  19. Program to delete mth element from an input string

  20. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

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