Understand how Java handles files.
These concepts are the main used concepts in the project solution, kindly read the provided resources if any is new to you.
Concepts | Resources |
---|---|
File Handling in Java | Edureka Java handling file |
Understand File, FileReader,and FileWriter class | Artical File class in Java |
Write into a file | DigitalOcean Artical - Java File Handling |
Write a program that create a text file, then write into that text file.
Do the implementation of the createFile
method:
- Create a file object of
FileWriter
class with the name that is given in the method argument. - Write into the file, by using the
write
method of the FileWriter class. - Close the file stream, by using the
close
method of the FileWriter class. - In the main method, call the
createFile
method.
public static void createFile(String fileName) throws IOException {
/* Your code here */
}