Java Tutorial

 
 
 
 
import java.io.*;

class  WritingBytes
{
    public static void main(String[] args) 
    {
          //Declare and initialize  a byte array
          byte cities[] = {(byte)\'D\',(byte)\'E\',(byte)\'L\',(byte)\'H\',(byte)\'I\',(byte)\'\\n\',
            (byte)\'M\',(byte)\'A\',(byte)\'D\',(byte)\'R\',(byte)\'A\',(byte)\'S\',(byte)\'\\n\',
            (byte)\'L\',(byte)\'O\',(byte)\'N\',(byte)\'D\',(byte)\'O\',(byte)\'N\',(byte)\'\\n\'};

          //Create an output file stream
          FileOutputStream fos =null;
          try{
                fos= new FileOutputStream(\"city.txt\");
                fos.write(cities);
                fos.close();
            }catch(IOException e){}

    }
}

    Related Post:
  1. Program to show the use of Nested Loops

  2. Program to show the use of Increment and Decrement Operators

  3. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  4. Program to show an example of Driving and using a Class

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

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

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

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

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

  10. Program to Display Output in triangular shape

  11. An applet program to display sum of two number of textField

  12. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

  13. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  14. Corba program of date operations

  15. Program of an applet to display alternate filled and empty circle

  16. Program of binary search tree

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

  18. Program to declare and initialize Integer variables and print them on the Standard Output Device

  19. Program to delete mth element from an input string

  20. Program to show the use of Do-While Loop

 
 
Didn't find what you were looking for? Find more on Program of writing Bytes to a File