Thanks a ton. Didn't know android allowed saving to mp3 directly
unlike an iphone.
On 31-Mar-09, at 5:32 PM, MrChaz wrote:
>
> Sure,
> Something like
>
> //Where the file comes from
> URL sourceURL = new URL("address");
> URLConnection conn = sourceURL.openConnection();
>
> InputStream inStream = sourceURL.openStream();
>
> // Where the file is going to go
> FileOutputStream outStream= new FileOutputStream("sdcard/file.mp3");
>
> //a read buffer
> byte[] bytes = new byte[20480];
>
> //read the first chunk
> int readBytes = file.read(bytes);
>
> //read the rest
> while (readBytes > 0){
> //Write the buffered chunk to the file
> outStream.write(bytes, 0, readBytes);
> readBytes = file.read(bytes);
> }
> inStream.close();
> outStream.close();
>
> should do it. I've typed that more or less by hand so it's missing
> error checking etc.
>
> On Mar 31, 8:10 am, idev <[email protected]> wrote:
>> Hi
>>
>> I am able to stream an mp3 at real time on my android phone. I wanted
>> to know if it is possible to save an mp3 file residing on a remote
>> location to my SD card.
>>
>> Any heads up is greatly appreciated.
>>
>> Thanks.
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---