字节流 文件输入流
public class InputStreanTest { public static void main(String[] args) { InputStream fis=null; try{ //2.创建文件输入对象 fis=new FileInputStream("D:\\doc\\test.txt"); //3.执行读操作 byte[]words =new byte[1024]; int len=0;//实际读取长度 System.out.println("文件内容: "); while((len=fis.read(words))>0){ System.out.println(new String(words,0,len)); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { //4.关闭输出流 try{ if (fis!=null){ fis.close(); } } catch (IOException e) { e.printStackTrace(); } } } }