/**
* 字节流和字符流的区别,
* (1)字符流带有缓冲,必须flush或close后数据才会从缓存中写入磁盘文件。
* 字节流直接写文件。
* (2)字符流在创建流的时候,指定编码,字节流在文件输出的时候指定编码
* jdk中哪些是字符流哪些是字节流,一句话,以Writer、Reader结尾的都是字符流,以Stream结尾的都是字节流。
* (3)字符流都是对字节流的封装
*
*/
//当前测试所用系统为中文windows XP 系统 默认GB2312编码
//**************************写操作*********************************
/*FileOutputStream fileOutputStream = new FileOutputStream(new File("C:\test\ok.txt"));
fileOutputStream.write("联通".getBytes());//系统默认编码
*/
/*FileOutputStream fileOutputStream = new FileOutputStream(new File("C:\test\ok.txt"));
fileOutputStream.write("联通".getBytes("UTF-8"));*/
/* OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream("C:\test\ok.txt")); //系统默认编码
outputStreamWriter.write("联通");
outputStreamWriter.close();*/
/*OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream("C:\test\ok.txt"),"UTF-8");
outputStreamWriter.write("联通");
outputStreamWriter.close();*/
/*OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream("C:\test\ok.txt"),"UTF-8");
outputStreamWriter.write("联通");
outputStreamWriter.close();*/
//****************************读取操作******************************
/*FileInputStream fileInputStream = new FileInputStream(new File("C:\test\ok.txt"));
byte[] readValue = new byte[1024];
fileInputStream.read(readValue);
System.out.println(new String(readValue)); //系统默认方式解码*/
/*FileInputStream fileInputStream = new FileInputStream(new File("C:\test\ok.txt"));
byte[] readValue = new byte[1024];
fileInputStream.read(readValue);
System.out.println(new String(readValue,"UTF-8"));*/
/*InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream("C:\test\ok.txt")); //系统默认解码
char[] content = new char[1024];
inputStreamReader.read(content);
System.out.println(content);*/
/*InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream("C:\test\ok.txt"),"UTF-8"); //系统默认解码
char[] content = new char[1024];
inputStreamReader.read(content);
System.out.println(content);*/