Create Multiple Files using Java
Submitted by donbermoy on Tuesday, May 13, 2014 - 22:54.
Today, I will teach you how to create different files using Java. Here, we will just use the io package.
So, now let's start this tutorial!
1. Open JCreator or NetBeans and make a java program with a file name of CreateFiles.java.
2. Import java.io package. Hence we will use an input/output in creating files.
3. In your main, initialize the following files and its file extension.
- For word document
- For rich text file
- For text file
- For excel file
- For access file
4. Now, create a try and catch method. In your try method, do the following code. This will trigger to create files.
In your Catch method, prefer to catch IOException then use printStackTrace() method. This will help to trace the exception and identify which method causes the bug.
Output:
Here's the full code of this tutorial:
Hope this helps! :)
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- import java.io.*;
- try
- {
- }
- {
- e.printStackTrace();
- }

- import java.io.*;
- public class CreateFiles
- {
- {
- try
- {
- {
- e.printStackTrace();
- }
- }
- }
Add new comment
- 258 views