I am trying to download a SWF file using jersey from a web resource.
I wrote the following code, but I cannot save the file correctly:
Response response = webResource.request(MediaType.APPLICATION_OCTET_STREAM) .cookie(cookie) .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); String binarySWF = response.readEntity(String.class); byte[] SWFByteArray = binarySWF.getBytes(); FileOutputStream fos = new FileOutputStream(new File("myfile.swf")); fos.write(SWFByteArray); fos.flush(); fos.close();
Save to suggest that the response returns a SWF file, since response.getMediaType returns application/x-shockwave-flash .
However, when I try to open SWF, nothing happens (there is also no error), which suggests that my file was not created from the response.
source share