FileReader、FileWriter的拷贝
FileReader read = new FileReader("H:\\aaa\\1.txt"); FileWriter write = new FileWriter("H:\\bbb\\1.txt"); int c=-1;//此时的c是字符数组b的长度,和字节流的字节数组不一样 char[] b= new char[200]; while((c = read.read(b))!=-1) { write.write(b,0,c); } /** int c=-1;//此时的c是每次读取的字符的字节码char while((c = read.read())!=-1) { write.write(c); } **/FileInputStream、FileOutputStream的拷贝
FileInputStream in = new FileInputStream("H:\\aaa\\haha.txt"); FileOutputStream out = new FileOutputStream("H:\\bbb\\2.txt"); int c=-1;//此时的c是字节数组b的长度 byte[] b= new byte[200]; while((c = in.read(b))!=-1) { out.write(b,0,c); }缓冲流 也分为字符、字节两种 字节缓存流没有新的方法 BufferReader String readLine() 读取一个文本行
BufferWriter void newLine () 写入一个行分隔符