1. ①字节流继承于InputStream,字节流主要处理byte类型,操作中不存在缓存,字节比较常用;
②字符流继承于InputStreamReader;
public class Test1{
public static void main(String[] args) throws IOException{
File f=new File("d:"+File.separator+"text.txt");
OutputStream os=new FileOutputStream(f);
String s="hello word";
Byte[] b = s.getByte[];
os.write(b);
os.close();
}
}
public class Test2{
public static void main(String[] args) throws IOException{
File f=new File("e:"+File.separator+"text.txt");
InputStrean is=new FileInputStream(f);
Byte[] b=new Byre[(int)f.length()];
is.read(b);
is.close();
}
}