I am new in java and now learning the File io . but i am very confused about the io as there are many objects to deal with it (FileReader, FileWriter, BufferedReader, BufferedWriter, FileInputStream, FileOutputStream … and may be there are more).
I want to know that what is the most efficient process for File io(What should i use ?).i don’t want any encoding. i want just processing text files.
Any simple example code will be greatly helpful.
Thank you.
First important point to understand and remember:
Stream: sequence of bytes.
Reader/Writer: sequence of characters (Strings)
Don’t mix them, don’t translate for one to another if not necessary, and always specify the encoding.
Some quick recipes:
To read a file as a sequence of bytes (binary reading).
The same adding buffering:
To read a file as a sequence of characters (text reading).
To add line-oriented buffering (to read lines of text)
To output/write is practically the same (output/writer)