This java program,creates a text file in the address specified if is not present and writes the content in this text file.If the text file is already present in the specified address, the content will be appended to the previously existing content.This program requires two class file,one is the java main class file(WriteText.java) and other is the java class file(WriteFile.java) which wites the content into the text file.Steps are given below.
Steps- Select Java form the categories and Java Application from the projects, click Next.
- Set the Project name as writeText and set the Create Main Class, click Finish.
- Under the project "writeText", you can see two files, double click the Source Packages,you can see a package by name " writetext " ,double click it you will find the Java Main Class File, WriteText.java.
- Right click the package by name " writetext " and select New -> Other
- From Categories select Java and from File Types select Java Class, click Next
- Set the Class Name as "WriteFile.java" and ensure the package name is " writetext".
Now open the
WriteText.java, remove the existing code and paste the following code :