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 of insertion sort


  3. Program to display attributes of a specified file

  4. Program to evaluate following investment equation V=P(1+R)^N

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

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

  7. Program to show the use of For Loop

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

  9. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  10. Program to show the use of some Character Methods

  11. Write a program for restaurant

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

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

  14. An applet program of passing parameters

  15. Application for counting factorial of a given number

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

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

  18. Program to print some text on the same line using multiple print statements

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

  20. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

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