filmov
tv
Create and write to Files in Java - Java tutorial - w3Schools - Chapter-52 English
Показать описание
To create a file in Java, we can use the createNewFile() method. This method returns a boolean value: true if the file was successfully created, and false if the file already exists. Note that the method is enclosed in a try...catch block. This is necessary because it throws an IOException if an error occurs (if the file cannot be created for some reason).
We use the FileWriter class together with its write() method to write some text to the file . Note that when we are done writing to the file, we should close it with the close() method.
We use the FileWriter class together with its write() method to write some text to the file . Note that when we are done writing to the file, we should close it with the close() method.