を使用して、zipファイルをダウンロードして、私はksoapのliabry.Iを使用して、サーバーからzipファイルをダウンロードしたいが、BASE64でデータを取得していますzipファイルとしてどのようにbase64に変換し、それを保存するという解決策を与えてくださいアンドロイドどのように石鹸liabrary
0
A
答えて
-2
このコードは私をdownlad APKに助け、sdカードに保存する。また、これはあなたを助けるかもしれ
...
public class SaveInBackground extends AsyncTask<String,Integer,String> {
View v;
OutputValue ov;
Boolean isError= false;
public SaveInBackground(View v,OutputValue ov){
this.v = v;
this.ov = ov;
}
@Override
protected void onPreExecute(){
Message.setText("Downloading...");
isToLoop =true;
new Thread(new Runnable() {
@Override
public void run() {
while (isToLoop) {
SystemClock.sleep(500);
runOnUiThread(new Runnable() {
@Override
public void run() {
int count = bar.getProgress() + 1;
bar.setProgress(count);
}
});
if(isToLoop)
break;
}
}
}).start();
}
@Override
protected void onProgressUpdate(Integer... values) {
bar.setProgress(values[0]);
}
@Override
protected String doInBackground(String... params) {InputStream input = null;
OutputStream output = null;
HttpURLConnection connection = null;
try {
URL url = new URL(Globle.Infosoft_serverLink.replace("/Service.asmx/","")+ov.url);
connection = (HttpURLConnection) url.openConnection();
connection.connect();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
isError = true;
return "Server returned HTTP " + connection.getResponseCode()
+ " " + connection.getResponseMessage();
}
int fileLength = connection.getContentLength();
input = connection.getInputStream();
//publishProgress(80);
String path = Environment.getExternalStorageDirectory()+"/"+ov.Name+".apk";
output = new FileOutputStream(path);
byte data[] = new byte[4096];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
if (fileLength > 0) // only if total length is known
publishProgress((int) (total * 100/fileLength));
output.write(data, 0, count);
}
return path;
}
catch (Exception e) {
isError =true;
Snackbar.make(v,"Error while accessing storage.",Snackbar.LENGTH_LONG).show();
return null;
}finally {
try {
if (output != null)
output.close();
if (input != null)
input.close();
} catch (IOException ignored) {
}
if (connection != null)
connection.disconnect();
}
}
@Override
protected void onPostExecute(String result){
if(!isError) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(result)), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
Message.setText("Downloaded");
reset(v);
}
}
+1
これは質問ではありません –
0
byte[] bytes;
byte[] data = result.getBytes("UTF-8");
File outputFile = new File(mediaStorageDir.getAbsolutePath(), + "filename.zip");
new FileOutputStream(outputFile);
bytes = Base64.decode(data, Base64.DEFAULT);
File filepath = new File(Environment.getExternalStorageDirectory(), "Folder/" + "filename.zip");
OutputStream pdffos = new FileOutputStream(filepath);
pdffos.write(bytes);
pdffos.flush();
pdffos.close();
関連する問題
- 1. どのようにPHPの石鹸サーバーは、石鹸クライアントのCプログラムを聞くことができますか?
- 2. は石鹸
- 3. 石鹸のログイン.net
- 4. シルバーライトの石鹸サーバーアドレス
- 5. 石鹸のダイナミックスジャッジド値
- 6. この石鹸WSDLにプロパティを追加する方法アンドロイド
- 7. エキスXdocument石鹸レスポンスボディ
- 8. シュガーCRM石鹸API
- 9. JIRA石鹸API:スクリーンショットアプレット
- 10. 石鹸XMLとPHP
- 11. PHPで石鹸に接続
- 12. grails/groovyのWSClient石鹸クライアント
- 13. 石鹸接続のストリームエラー
- 14. デシリアライズ石鹸応答のC#
- 15. 軸の変更石鹸:アドレス
- 16. 一般的な石鹸クライアントツール
- 17. 石鹸機能記述
- 18. SImple必要な石鹸
- 19. は石鹸を照会しようとすると:XPathの
- 20. 石鹸のボディは常に空白
- 21. PHPの石鹸接続の拒否
- 22. 石鹸応答のヘッダーの日付
- 23. 次のように私の完全な石鹸strucuteがあるPHP
- 24. コード:石鹸:サーバーメッセージ:stamps.com APIの統合
- 25. ラクダ石鹸のヘッダーを変更する
- 26. authヘッダー付きのnpm石鹸
- 27. JSPで石鹸の応答を表示
- 28. 軸2石鹸サーバーの設定
- 29. 自己石鹸サーバーへの2回目の石鹸呼び出しは、サーバーがセグメンテーションを生成するようになります
- 30. 休憩や石鹸を使うべきでしょうか
あなたはこのような何かお読みください:https://stackoverflow.com/questions/19980307/stream-decoding-of-base64-dataを、変換しますBase64ファイルへのファイルストリーム。とにかく、より簡単にするために、より詳細といくつかのサンプルコードを提供してください – Panciz