8亮8仔8

io流(详询请加qq:2085920154)

import java.io.File; import java.io.FileInputStream; import java.io.IOException;

public class ioTest {

 public static void main(String[] args) {

  File file=new File("f:"+File.separator+"test.txt");

   FileInputStream fis = null;

   try { 

      fis = new FileInputStream(file);

       byte[] b = new byte[2];

    int num = 0; 

   while((num = fis.read(b))!=-1){

     System.out.print("******"+num);  

System.out.println("--------"+new String(b,0,num));  

    }   

        }   catch (IOException e) {

    e.printStackTrace();

   }

 }

}

 

 

******2--------先
******2--------休
******2--------息
******2--------吧
******1--------1

总结:

1.String(byte[] byte,int start,int length)的length是num的长度

posted on 2016-04-09 22:26  8亮8仔8  阅读(177)  评论(0编辑  收藏  举报

导航