if (file.doesExist() && file.isDirectory()) {
throw new IOException("File is a directory: " + file);
} else if (file.doesExist() && !file.isWritable()) {
throw new IOException("Can not write to file: " + file);
}
OutputStream os = file.createOutputStream(0);
try {
ack();
byte[] buffer = new byte[8192];
while (length > 0) {