Skip to content

Commit

Permalink
Java6 support for jersey2 (#4033)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1w1m8 authored and wing328 committed Oct 19, 2016
1 parent c3a12cb commit 60a52ee
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;

import java.io.IOException;
import java.io.InputStream;

{{^supportJava6}}
import java.nio.file.Files;
{{/supportJava6}}
{{#supportJava6}}
import org.apache.commons.io.FileUtils;
{{/supportJava6}}
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -521,7 +527,13 @@ public class ApiClient {
public File downloadFileFromResponse(Response response) throws ApiException {
try {
File file = prepareDownloadFile(response);
{{^supportJava6}}
Files.copy(response.readEntity(InputStream.class), file.toPath());
{{/supportJava6}}
{{#supportJava6}}
// Java6 falls back to commons.io for file copying
FileUtils.copyToFile(response.readEntity(InputStream.class), file);
{{/supportJava6}}
return file;
} catch (IOException e) {
throw new ApiException(e);
Expand Down

0 comments on commit 60a52ee

Please sign in to comment.