Best Way to read/write data using loop

BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
long curPos = startPos;
int bytesRead = -1;
byte[] buffer = new byte[BUFFER_SIZE];
while ((bytesRead = bis.read(buffer)) != -1) {
    fos.write(buffer, 0, bytesRead);
}