File Operations in Java

File Operations in Java
File operations plays an important role in java, Reading a file, renaming, deleting etc. In this article we are going to see some file operations,

  • Creating a file
  • Writing a content into that file
  • Reading the content from the file

Before we proceed to the coding, it is important for us to get familiar regarding some Input/Output methods

File – Used to create an object for file
FileReader – Used to read characters
BufferedReader – Enhances the filereader by reading a more data and storing it in buffer
FileWriter – Write characters to a file
BufferedWriter – Enhances filewriter by writing more data
PrintWriter – used for enhancement and has other methods than bufferedwriter

NOTE:
Please note that,

File file = new File(“notes.txt”); –> This does not create a new File, This just creates an object

Output:
op1

Leave a Reply

Your email address will not be published. Required fields are marked *