You know when they say“One does not simply understands Java” ?Well its not that hard.You see, I´ve been working with files lately and a friend ofmine had an hard time understanding the concept of writingand reading files in java. So this one goes out not only for him but also for everyonehaving trouble with this concept.Enjoy and hopefully you will find all the answers in thispresentation.
Imports• First of all, we will be using resources from the ‘java.io package’, so go ahead and import this at the TOP of your code.Instead of using ‘*’ you can specify what youreally want to import but for now it works justfine.
Building the program• Now we will need a class and a ‘main’ method.
Recipe to write• Youll now need the following:-A File object – It creates a file if you don’t have one already-A FileWriter object – The output stream. The one who writes.-A BufferedWriter object – Sends data to the output streamNow you might ask “Why do we create the one who sends data (BufferedWriter) to the output stream (FileWriter) first?” Basically because BufferedWriter receives the output stream as a parameter so you need to create it first.