How can I save correctly a pdf file from http response on Android? byte stream is received through rest API. I tried this:
try
{
File outputFile = new File("/storage/emulated/0/Android/data/package/files/", "cot.pdf");
FileOutpuStream fos = new FileOutputStream(outputFile);
byte [] bytes = data.getBytes();//byte stream response
fos.write(bytes);
fos.flush();
fos.close();
}
catch(Exception e)
{
e.printStackTrace();
}
and file and data is written, but when pdf is opened, there's only blank pages, what's wrong?