FileReader rd=new FileReader("new.mp4");
FileWriter wr=new FileWriter("output.mp4");
int ch;
while((ch=rd.read())!=-1)
wr.write(ch);
wr.flush();
wr.close();
When I use the FileReader and FileWriter to read and write an mp4 file, the output.mp4 file can't be rendered well. But when I use FileInputStream and FileOutputStream instead it worked well.
So can I conclude FileReader and FileWriter are only for reading and writing text?
Yes, your conclusion is correct subclasses of
ReaderandWriterare for reading/writing text content.InputStream/OutputStreamare for binary content. If you take a look at the documentation: