fileoutputstream example

We are going to discuss about fileoutputstream in java. The fileoutputstream class extends the java.io.FileOutputStream. It has two stream Byte and Charaters.The OutputStream abstract class use to write data to a file. The FileOutputStream is the subclass of the OutputStream abstract class.

fileoutputstream example

We are going to discuss about fileoutputstream in java. The fileoutputstream class extends the java.io.FileOutputStream. It has two stream Byte and Charaters.The OutputStream abstract class use to write data to a file. The FileOutputStream is the subclass of the OutputStream abstract class.

fileoutputstream example

fileoutputstream example

We are going to discuss about fileoutputstream in java. The fileoutputstream class extends the java.io.FileOutputStream. It has two stream Byte and Charaters.The OutputStream abstract class use to write data to a file. The FileOutputStream is the subclass of the OutputStream abstract class. The FileOutputStream is used to write data to a file than make the text file as a particular path in a system and we have used PrintStream class that extends the java.io.PrintStream. It writes data to another stream, you can write data like Charecter,bytes,integers,floats,String type types,

Example

package FileHandling;

import java.io.FileOutputStream;
import java.io.PrintStream;

public class FileInputStream {
	public static void main(String[] args) {
		FileOutputStream stream;
		PrintStream printStream;

		try {

			stream = new FileOutputStream("c://RoseIndia.txt");

			printStream = new PrintStream(stream);
			//create a new print stream

			printStream.println("The FileOutputStream  is used to write data to a file.");

			System.out.println("successfully created file and write ");

			printStream.close();
		} catch (Exception e) {
			System.err.println("Error writing to file");
		}
	}

}

OutPut

Download Sourse code