以下のコードで外部ストレージへのzipファイル保存ができているのですが
外部ストレージが無いときでもファイル保存を可能するため内部ストレージへの保存するように改変したいのですが
どのように変更すればよろしいでしょうか
URL url = new URL(stringUrl); // テンポラリファイルの設定 File outputFile = File.createTempFile("example", ".zip"); FileOutputStream fos = new FileOutputStream(outputFile); // HTTP接続開始 HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); // ダウンロード開始 InputStream is = connection.getInputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = is.read(buffer)) != -1) { fos.write(buffer, 0, len); } fos.close(); is.close();
あなたの回答
tips
プレビュー