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 that demonstrates type casting

  2. Program to reverse the number eg given no : - 12345, output want :- 54321

  3. Program that reads and writes random access file

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

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

  6. Program to perform Merge Sort

  7. Corba program of reverse string

  8. Program to show the use of Nested Loops

  9. Program to show the use of Comparison operator (==) for comparing Strings

  10. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  11. Program of insertion sort

  12. Program of linear search

  13. Program to show the use of Switch Statement for the same statement for several different case labels

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

  15. Program to represent a bank account

  16. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  17. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  18. An applet program that displays random dot

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

  20. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

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