Merge commit '17455a3' into master_merge
This commit is contained in:
@@ -38,6 +38,10 @@ public class DelayedDiskWrite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(final String filePath, final Writer w) {
|
public void write(final String filePath, final Writer w) {
|
||||||
|
write(filePath, w, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(final String filePath, final Writer w, final boolean open) {
|
||||||
if (TextUtils.isEmpty(filePath)) {
|
if (TextUtils.isEmpty(filePath)) {
|
||||||
throw new IllegalArgumentException("empty file path");
|
throw new IllegalArgumentException("empty file path");
|
||||||
}
|
}
|
||||||
@@ -54,16 +58,18 @@ public class DelayedDiskWrite {
|
|||||||
mDiskWriteHandler.post(new Runnable() {
|
mDiskWriteHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
doWrite(filePath, w);
|
doWrite(filePath, w, open);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWrite(String filePath, Writer w) {
|
private void doWrite(String filePath, Writer w, boolean open) {
|
||||||
DataOutputStream out = null;
|
DataOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
|
if (open) {
|
||||||
out = new DataOutputStream(new BufferedOutputStream(
|
out = new DataOutputStream(new BufferedOutputStream(
|
||||||
new FileOutputStream(filePath)));
|
new FileOutputStream(filePath)));
|
||||||
|
}
|
||||||
w.onWriteCalled(out);
|
w.onWriteCalled(out);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
loge("Error writing data file " + filePath);
|
loge("Error writing data file " + filePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user