Register Now

Login

Lost Password

Enter your email to reset your password.

BY Author

Java – The FileOutputStream class

The FileOutputStream class is used to write data in the form of bytes.

Declaration

class FileOutputStream extends OutputStream

Constructors of FileOutputStream (CLICK HERE)

Methods defined in FileOutputStream (CLICK HERE)

Example

 import java.io.FileOutputStream;
 import java.io.IOException;

 class FileOutputStreamDemo 
 {
    public static void main(String args[]) throws IOException
    {
       FileOutputStream f = new FileOutputStream("alphabets.txt");
       for(int i = 65;i<91;i++)
       {
           f.write(i);
       }
     System.out.println("All UpperCase Alphabets wrote to the file alphabets.txt");
         f.close();
   }
 }

Output

All UpperCase Alphabets wrote to the file alphabets.txt

The text file “alphabets.txt” is created in the current working dictionary.

Java Programming Language FileOutputStream Class in File Handling

Leave a reply