In Java, FileOutputStream is an bytes stream class to handle the raw binary data. To write it, you have to convert the data into bytes, see below example

FileOutputStream example

package com.mkyong.file;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
 
public class WriteFileExample 
{
    public static void main( String[] args )
    {	
    	try{
    		String content = "This is the text content";
 
    		File file =new File("newfile.txt");
 
    		//if file doesnt exists, then create it
    		if(!file.exists()){
    		   file.createNewFile();
    		}
 
    		FileOutputStream fop=new FileOutputStream(file);
		//get the content in bytes
    		fop.write(content.getBytes());
		fop.flush();
	        fop.close();
 
                System.out.println("Done");
 
    	}catch(IOException e){
    		e.printStackTrace();
    	}
    }
}

Reference

  1. http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~