查一查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)
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)
int n;
byte[] temp=new byte[1024];
while((n=f.read(temp))!=-1){
...
...
}
将f中读入的内容byte数组 temp中,直到f中没有数据。