Java Tutorial


class  RWRandInt
    public static void main(String[] args) 
               FileOutputStream fos = new FileOutputStream(\"RandData.txt\");
               DataOutputStream dos = new DataOutputStream(fos);

               for (int i=0;i<20 ;i++ )  //for writing 20 integers to RandData.txt file
                    dos.writeInt((int)Math.random() * 100);

               //For Reading Data
               FileInputStream fis = new FileInputStream(\"RandData.txt\");
               DataInputStream dis = new DataInputStream(fis);
               for (int i=0;i<20 ;i++ )
                    int n = dis.readInt();
                   System.out.print(n + \"  \");
             }catch(Exception e) {}

    Related Post:
  1. Program to show an example of modifying String objects

  2. An applet program to draw Polygon Graph with given data

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

  4. Program to show the use of Bitwise Operator (~) Complement

  5. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  6. Program of Floyds Triangle

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

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

  9. Develop a CORBA based application for addition of two complex numbers and displaying the result on client side

  10. Program that takes a long sentence and a character from the client and count the occurrence of the character in the sentence at the server side

  11. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  12. Program using Switch case to compute the net amount to be paid by a customer

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

  14. Even number ,Prime no. ,Factorial of a number

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

  16. Program to show the use of some Math Methods

  17. Socket program of HTTP Server

  18. Program to show the use of Nested Loops

  19. Program to show an example of using a recursive method in a class

  20. Program to show an example of using user-defined package in a program

Didn't find what you were looking for? Find more on Program of storing and retrieving integers using data streams on a single file