# Java : Why PrintWriter,BufferedWriter and FileWriter



## TheGingerNinja (Dec 11, 2015)

I'm learning File Handling in Java and we are asked to initialize our methods in the File class like this :

FileWriter fw = new FileWriter ("Output.txt");
BufferedWriter bw = new BufferedWriter (fw);
PrintWriter pw = new PrintWriter (bw);

But I've handled files in Java before and I have initialized it like this before:

PrintWriter pw = new PrintWriter ("Output.txt");

What is "FileWriter" and "BufferedWriter" and why is it necessary to initialize it? What does it do and why do I need it??

Thanks,
Andrew


----------



## TheGingerNinja (Dec 11, 2015)

bump


----------



## Ent (Apr 11, 2009)

Your best bet with this sort of question is to look at the language documentation, which you can generally get online.
In this case, the answer you're after is here: 
https://docs.oracle.com/javase/7/docs/api/java/io/BufferedWriter.html


----------

