Your web service should send you some identifier about the file type. whether an array of bytes for an image or for a shared file. then only you can find out what type of file it is. after knowing the file type, you can convert the byte array to the desired file type. You can also write to a file. If you want to print this xml in logcat, you can use
String xmlData = new String(byte[] data); System.out.println(xmlData)
create a file (be it xml or image or anything else) if you know the file format
String extension = ".xml"
String filename = myfile+extension;
byte[] data =
File f = new File(givepathOfFile+filename );
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(data );
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
Thanks Deepak
source
share