字节输入流 FileInputStream
字节输入流 InputStream : 方法介绍: read(); 读取下一个字节 返回-1读取文件结束 close(); 复制文件 将数据aaa.txt复制到d盘 字节输入流读----》字节输出流写 package cn.lideng.demo1; import java.io.FileInputStream; import java.io.FileNotFoundException; //创建字节输入流的子类对象 //调用方法读取read //关闭资源 public class FileInputStreamDemo { public static void main(String[] args) { try { FileInputStream fis=new FileInputStream("d:\\b.txt"); int len=0; while((len=fis.read())!=-1){ System.out.println((char)len); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } package cn.lideng.demo1; import java.io.FileInputStream; public class FileInputStreamDemo1 { public static void main(String[] args) { try { FileInputStream fis=new FileInputStream("d:\\b.txt"); //创建字节数组 byte[] b=new byte[1024]; int len=0; while((len=fis.read(b))!=-1){ System.out.println(new String(b,0,len)); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }