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 Do-While Loop

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

  3. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

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

  5. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

  6. Program of concatenating and Buffering files

  7. Program to make directory

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

  9. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  10. File handling program to copy characters from one file to another

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

  12. Application for counting factorial of a given number

  13. RMI program of count server and client

  14. Program to show the use of Nested Loops

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

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

  17. Socket program of HTTP Server

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

  19. Program to show the use of Logical or Boolean Negation i.e. NOT (!)

  20. An applet program that creates string dynamically and displays it

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