FileInputStream是字节型文件输入流,而FileReader是字符型文件读取流。区别就在于,在流的传输过程中一个是以字节为单位,另一个是以字符(可以为一个字节,或多个字节)为单位。
读:
FileInputStream---》new FileInputStream(new File(path+name)).read(new byte[length]); new String(byte) 就能得到相应的字符串。
FileReader----> String str=new BufferedReader(new FileReader(new File())).nextline()!=null; 得到的str就是对应的输出字符串。
写:
FileOutputStream--》new FileOutputStream(new File(path+name)).write(byte[]);
FileWriter--> new FileWriter(new File(path+name)).write(string);