Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Difference between FileOutputStream and FileWriter

I was wondering what the exact difference is between Android's FileOutputStream and FileWriter class. When would it be most appropriate to use each one?

like image 915
laker Avatar asked Apr 29 '12 02:04

laker


1 Answers

If I remember correctly, FileOutputStream is more general purpose - it can be used for binary data or text data. FileWriter is used for text only.

http://docs.oracle.com/javase/1.4.2/docs/api/java/io/FileWriter.html

FileWriter is meant for writing streams of characters. For writing streams of raw bytes, consider using a FileOutputStream.

like image 191
les2 Avatar answered Oct 10 '22 06:10

les2