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. An application that combines several classes and interface

  2. Program to read command line arguments

  3. Program to show an example of using a Non-Static Nested Class

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

  5. Program to show the use of some Character Methods

  6. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

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

  8. Program of linear search

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

  10. Program to show an example of searching Strings for characters

  11. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  12. Program to show the comparing of Strings for equality

  13. Program to show the use of operator (<<) Shift Left filling with zero from the right

  14. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

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

  16. RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user

  17. Program sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

  18. Program to declare, initialize and print a String object

  19. Program to declare, initialize and print a StringBuffer object

  20. Encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time after each word in the sent

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