将流里面得数据填充到数组temp中,返回填充得个数,假如没有填充,那么返回-1,所以这是判断是否从流中取完数

解决方案 »

  1.   

    查一查API doc:
    FileInputStream:
    public int read(byte[] b)
             throws IOException
    Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available. Overrides:
    read in class InputStream
    Parameters:
    b - the buffer into which the data is read. 
    Returns:
    the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached. 
    Throws: 
    IOException - if an I/O error occurs.
    See Also:
    InputStream.read(byte[], int, int)
      

  2.   

    while写错了,应该是:FileInputStream f=...;
    int n;
    byte[] temp=new byte[1024];
    while((n=f.read(temp))!=-1){
    ...
    ...
    }
    将f中读入的内容byte数组 temp中,直到f中没有数据。