FileOutputStream is a class present in java.io package and child class of outputstream class. It Stores data in the form of bytes. It is used to create a text file.
In this program we are using BufferedReader class which is child class of Reader class is used to read data from keyboard.
BufferedReader file = new BufferedReader(new InputStreamReader(System.in));
Here file is the object of the FileOutputStream class that points to " test txt file, if the file is not present it creates a new file.
FileoutputStream file=new FileoutputStream("Hello.txt");
To close the file we have to close the associated streams.
Here is the Java Example for Create a File and Write Data in Java:
public static void main(String args)
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
FileOutputStream file = new FileOutputStream("Hello.txt");
System.out.println("Enter text and Type 'y' to Terminate");
System.out.println("File is Created");