import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
public boolean isRepeatable() {
return true;
}
public void setOnDatatransferProgressListener(OnDatatransferProgressListener listener) {
public boolean isRepeatable() {
return true;
}
public void setOnDatatransferProgressListener(OnDatatransferProgressListener listener) {
public void writeRequest(final OutputStream out) throws IOException {
//byte[] tmp = new byte[4096];
ByteBuffer tmp = ByteBuffer.allocate(4096);
int i = 0;
public void writeRequest(final OutputStream out) throws IOException {
//byte[] tmp = new byte[4096];
ByteBuffer tmp = ByteBuffer.allocate(4096);
int i = 0;
- FileChannel channel = new RandomAccessFile(this.file, "rw").getChannel();
+ // TODO(bprzybylski): each mem allocation can throw OutOfMemoryError we need to handle it
+ // globally in some fashionable manner
+ RandomAccessFile raf = new RandomAccessFile(mFile, "rw");
+ FileChannel channel = raf.getChannel();
while ((i = channel.read(tmp)) >= 0) {
out.write(tmp.array(), 0, i);
tmp.clear();
while ((i = channel.read(tmp)) >= 0) {
out.write(tmp.array(), 0, i);
tmp.clear();
}
} catch (IOException io) {
Log.e("FileRequestException", io.getMessage());
}
} catch (IOException io) {
Log.e("FileRequestException", io.getMessage());