URL経由で画像と動画を取得し、Androidデバイスにダウンロードするダウンロード機能を構築/コピーしました。
小さな画像をダウンロードする場合は問題ありません。しかし、(WLAN 経由で!) 以上のファイルを取得しようとすると、2MB文字通り何年もかかります! 25MBの動画などで約5分。
何がうまくいかないのでしょうか?
これが私のコードです:
        /* Open a connection to that URL. */
        URLConnection ucon = url.openConnection();
        /*
         * Define InputStreams to read from the URLConnection.
         */
        InputStream is = ucon.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        /*
         * Read bytes to the Buffer until there is nothing more to read(-1).
         */
        ByteArrayBuffer baf = new ByteArrayBuffer(50);
        int current = 0;
        while ((current = bis.read()) != -1) {
                baf.append((byte) current);
        }
        /* Convert the Bytes read to a String. */
        FileOutputStream fos = new FileOutputStream(file);
        fos.write(baf.toByteArray());
        fos.close();