Convert Binary stream into byte?

烈酒焚心 提交于 2019-12-09 07:33:27
|improve this question
                    try {
                    ht.call(SOAP_ACTION, envelope);

                    final SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
                    String str =DocumentResponse.toString();

                        byte[] decodedString = Base64.decode(str, Base64.DEFAULT);

                   File direct = new File(Environment.getExternalStorageDirectory() + "/Foldername");

                      if(!direct.exists())
                      {
                          direct.mkdir();
                      }

                    File photo=new File(Environment.getExternalStorageDirectory() + "/Foldername",Filename);


                  if (photo.exists())
                  {
                        photo.delete();
                  }

                  try {
                    FileOutputStream fos=new FileOutputStream(photo.getPath());

                    fos.write(decodedString);
                    fos.close();

                    ContentValues values= new ContentValues();

                  }
                  catch (java.io.IOException e) 
                  {
                    Log.e("PictureDemo", "Exception in photoCallback", e);
                  }
                }


                catch (Exception e) {
                e.printStackTrace();
            }

Convert your String into Base64 decode.

Example: byte[] decodedString = Base64.decode(str, Base64.DEFAULT);

Use that byte to save the file in the SDCard.

Example:fos.write(decodedString);

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!