32
32
public abstract class FileAsyncHttpResponseHandler extends AsyncHttpResponseHandler {
33
33
34
34
protected final File mFile ;
35
+ protected final boolean append ;
35
36
private static final String LOG_TAG = "FileAsyncHttpResponseHandler" ;
36
37
37
38
/**
@@ -40,9 +41,20 @@ public abstract class FileAsyncHttpResponseHandler extends AsyncHttpResponseHand
40
41
* @param file File to store response within, must not be null
41
42
*/
42
43
public FileAsyncHttpResponseHandler (File file ) {
44
+ this (file , false );
45
+ }
46
+
47
+ /**
48
+ * Obtains new FileAsyncHttpResponseHandler and stores response in passed file
49
+ *
50
+ * @param file File to store response within, must not be null
51
+ * @param append whether data should be appended to existing file
52
+ */
53
+ public FileAsyncHttpResponseHandler (File file , boolean append ) {
43
54
super ();
44
55
AssertUtils .asserts (file != null , "File passed into FileAsyncHttpResponseHandler constructor must not be null" );
45
56
this .mFile = file ;
57
+ this .append = append ;
46
58
}
47
59
48
60
/**
@@ -53,6 +65,7 @@ public FileAsyncHttpResponseHandler(File file) {
53
65
public FileAsyncHttpResponseHandler (Context context ) {
54
66
super ();
55
67
this .mFile = getTemporaryFile (context );
68
+ this .append = false ;
56
69
}
57
70
58
71
/**
@@ -127,7 +140,7 @@ protected byte[] getResponseData(HttpEntity entity) throws IOException {
127
140
if (entity != null ) {
128
141
InputStream instream = entity .getContent ();
129
142
long contentLength = entity .getContentLength ();
130
- FileOutputStream buffer = new FileOutputStream (getTargetFile ());
143
+ FileOutputStream buffer = new FileOutputStream (getTargetFile (), this . append );
131
144
if (instream != null ) {
132
145
try {
133
146
byte [] tmp = new byte [BUFFER_SIZE ];
0 commit comments