Java Blog

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

  2. An applet program to perform quick sort

  3. Program to read bytes from a file

  4. Program to show the use of Conditional OR Operator (||) in If Statements

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

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

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

  8. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

  9. RMI program of count server and client

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

  11. Program to read input from the Standard Input Device

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

  13. Develop a CORBA application that takes a string from client and returns whether it is palindrome

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

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

  16. Program to check the start and end of a String

  17. File handling program to display directory contents

  18. Program to read command line arguments

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

  20. An applet program to display Vertical Color Bar

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