Follow the code may will help you.
URL url = new URL(path);
URLConnection cn = url.openConnection();
cn.connect();
InputStream stream = cn.getInputStream();
if (stream == null)
throw new RuntimeException("stream is null");
if (BTAG)
Log.d(TAG, TAG + " File temp" +
audios_local[currentPosition]);
FileOutputStream out = new FileOutputStream(temp);
byte buf[] = new byte[128];
do {
int numread = stream.read(buf);
if (numread <= 0)
break;
out.write(buf, 0, numread);
} while (true);
try {
stream.close();
} catch (IOException ex) {
if (BTAG)
Log.d(TAG, TAG + " " + ex.toString());
}
I can read file bigger than 5MB.
2012/4/5 Kostya Vasilyev <[email protected]>
> Perhaps your base64 encoded data doesn't contain line breaks, or contains
> too few of them?
>
> Causing the readline() to try and read the entire 5 MB (or a large portion
> of it) in memory?
>
> For email content (since you mentioned K9) it's common to line-wrap base64
> data at some reasonable line size, like 76 characters (you know, many
> people still use DOS, even in this day and age).
>
> The same principle could apply to web data.
>
> Besides, line breaks do not have any significance for base64 encoded data
> (unlike, e.g. quoted-printable, or format-flowed text/plain), so you could
> just ignore the line structure.
>
> I'm sure there is piece of code somewhere in K9 sources that can decode
> base64 data on the fly without excessive buffering.
>
> There is also this:
>
> http://developer.android.com/reference/android/util/Base64InputStream.html
>
> ... which is part of Android starting with API 8, but hey, the sources are
> only a few clicks away.
>
> -- K
>
> 4 апреля 2012 г. 22:27 пользователь FractalBob <[email protected]>написал:
>
>
>>
>> On Apr 4, 8:48 am, TreKing <[email protected]> wrote:
>> > On Wed, Apr 4, 2012 at 10:38 AM, FractalBob <[email protected]> wrote:
>> > > The data, a kind of mail attachment, is a music file
>> >
>> > Why are you reading lines from this data then?
>> >
>> The data is coming in Base 64 encoded from the Web app and then passed
>> directly to the processing application. This scheme works fine for all
>> known types of data
>> > > and is eventually loaded into an MP3 player.
>> >
>> > What does that mean?
>> >
>> > I can't simply point the player to the file, unfortunately; too much
>> >
>> > > legacy code.
>> >
>> > Not sure what that means.
>> >
>> My app is based on the K9 Mail mail client and it expects the data
>> delivered to its providers in a certain format.
>> >
>> ---------------------------------------------------------------------------
>> ----------------------
>> > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
>> > transit tracking app for Android-powered devices
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en