Created
December 25, 2014 21:00
-
-
Save NikolaDespotoski/18029c3926eacf1b7fc0 to your computer and use it in GitHub Desktop.
Retrofit StringTypedOutput, it can be used for deserializing XML or just pulling a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.io.OutputStream; | |
import retrofit.mime.TypedOutput; | |
public class StringTypedOutput implements TypedOutput { | |
private final byte[] xmlBytes; | |
StringTypedOutput(byte[] xmlBytes) { | |
this.xmlBytes = xmlBytes; | |
} | |
@Override | |
public String fileName() { | |
return null; | |
} | |
@Override | |
public String mimeType() { | |
return "application/xml; charset=UTF-8"; | |
} | |
@Override | |
public long length() { | |
return xmlBytes.length; | |
} | |
@Override | |
public void writeTo(OutputStream out) throws IOException { | |
out.write(xmlBytes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment