Java program demonstrating the usage of FileOutputStream Class in package

FileOutputStream creates an OutputStream that you can use to write bytes to a file.

//Java Program demonstrating the FileOutputStream Class in package

// Demonstrate FileOutputStream.

class FileOutputStreamDemo {
	public static void main(String args[]) throws Exception {
		String Source = "Hello!! What are all of you doing???";
		byte buf[] = Source.getBytes();//Creating Byte Array
		OutputStream f1 = new FileOutputStream("FileWrite.txt");
		OutputStream f2 = new FileOutputStream("FileWrite2.txt");
		for (int i=0; i < buf.length; i += 3) {

No output is shown.  It creates a two  Files.

One called FileWrite.txt and write the text Hello!! What are all of you doing???.

FileWrite2.txt contains “Hl!h eloy i?”

Look for the Files in the Directory in which your program is there.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s