BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-29-2010, 01:02 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Dec 2009
Location: Sri Lanka
Model: 9000
PIN: N/A
Carrier: Software Engineer
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Download Files

Please Login to Remove!

Hi,

Currently I am developing an application which let users to download MP3 files from a web server. As well as I am downloading images, XML files from the same web server. However images and XML files downloading without any bug. I downloaded 250 KB image as well. But when I trying to download MP3 files it's not working. May be time out. I don't know exactly. Is there any way to do this. Any sample source code available. I will put my source code method here for further details. This code works fine for all XML and Image files which I downloaded so far.

public void downloadAlbumImage(String AlbumID, String imgURL)
{try {HttpConnection connection = null;InputStream inputStream = null;connection = (HttpConnection) Connector.open(imgURL , Connector.READ_WRITE, true);inputStream = connection.openInputStream();FileConnection dest = (FileConnection)Connector.open(getRootFileSystem(A NY_STORAGE_ENGINE) +SystemSettings.strParentDirectory + SystemSettings.strOfflineImageDirectory + AlbumID + SystemSettings.strStoredImageExtension,Connector.R EAD_WRITE);if (!dest.exists()) {dest.create(); }OutputStream outStream = dest.openOutputStream();byte[] Buffer = new byte[1024];int length = -1; while ((length = inputStream.read(Buffer)) > 0) {outStream.write(Buffer, 0 , length); }outStream.close();} catch ( Exception e ) {}}
public void downloadAlbumImage(String AlbumID, String imgURL)
{
try {
HttpConnection connection = null;InputStream inputStream = null;

connection = (HttpConnection) Connector.open(imgURL , Connector.READ_WRITE, true);

inputStream = connection.openInputStream();FileConnection dest = (FileConnection)Connector.open(getRootFileSystem(A NY_STORAGE_ENGINE) +SystemSettings.strParentDirectory + SystemSettings.strOfflineImageDirectory + AlbumID + SystemSettings.strStoredImageExtension,Connector.R EAD_WRITE);

if (!dest.exists()) {
dest.create();
}

OutputStream outStream = dest.openOutputStream();

byte[] Buffer = new byte[1024];
int length = -1;
while ((length = inputStream.read(Buffer)) > 0) {
outStream.write(Buffer, 0 , length);
}
outStream.close();


} catch ( Exception e ) {
}}
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

SQUARE D 8020-SMM-100 MEMORY MODULE *NEW NO BOX*
$369.0
SQUARE D 8020-SMM-100 MEMORY MODULE *NEW NO BOX* picture1756-L62 CPU MODULE 4MB MEMORY CONTROLLOGIX - New Never Used - Out of Box -
$1000.0
1756-L62 CPU MODULE 4MB MEMORY CONTROLLOGIX - New Never Used - Out of Box - pictureLecroy 8800/10 Memory Module CAMAC Crate
$50.0
Lecroy 8800/10 Memory Module CAMAC Crate pictureSuper Lumbar Support Pillow for Back Pain While Sleeping - Medical Grade Memory
$56.51
Super Lumbar Support Pillow for Back Pain While Sleeping - Medical Grade Memory pictureAEG MODICON AS-506P-002 MEMORY MODULE *NEW IN BOX*
$3838.0
AEG MODICON AS-506P-002 MEMORY MODULE *NEW IN BOX* picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.