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 Arrays of String

  2. Program to show an example of using a Static Nested Class outside the Top-Level Class

  3. An applet program of showing new document using showDocument(URL) method

  4. An applet program to draw concentric circle in center of the canvas

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

  6. Program of writing Bytes to a File

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

  8. Corba program to Write a Echo server and client with UDP server and client

  9. Program to show an example of Concatination of Strings

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

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

  12. An applet program of passing parameters

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

  14. Program that will count the number of lines in each file that is specified on the command line

  15. Write a program for restaurant

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

  17. Program to show the use of Logical OR Operator (|) in If Statements

  18. Program to show the use of operator (&gt;&gt;) Shift Right, propagating the sign bit from the left

  19. Program to show an example of using Abstract Class and Abstract Method

  20. Define an array of ten String elements each containing an arbitrary string of the form “month/day/year”

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