0
DataOutputStream lWriter = new DataOutputStream(connection.getOutputStream());
int bytesRead = 0;
int offset = 0;
byte[] bytes = new byte[1048576]; // read 1MB at a time
RandomAccessFile f = new RandomAccessFile(xmlFile, "rw");
while(bytesRead != -1){
offset += f.read(bytes, offset, bytes.length);
if (bytesRead != -1){
lWriter.write(bytes, 0, bytes.length);
}
}
와 RandomAccessFile의에서 읽기를 가졌어요. 인수 오프셋과 길이를 잘못 오용하고 있습니다. 덩어리로 읽을 때마다 덩어리 크기만큼 오프셋을 이동해야합니까? 어쩌면 적은 시간에 읽고 작은 버퍼를 사용해야할까요?이 문제가 DataOutputStream 정렬에 서면 내가 f.read에서 경계 예외에서 인덱스를 얻고이 코드()와 버퍼
현재 나는이 구현 작업이,하지만 난 메모리 사용에 대한 걱정 : 어떤 도움
DataOutputStream lWriter = new DataOutputStream(connection.getOutputStream());
lWriter.write(fileToBytes(xmlFile));
감사합니다!
while ((count = in.read(buffer)) > 0)
{
out.write(buffer, 0, count);
// bytesRead += count; // if you are counting
}
루프 수많은 오류가 다음과 같이 자바 스트림을 복사 할