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

Leybonol LVO 420 Special oil for vacuum pumps Oerlikon Leybold L 420 01 1 Liter
$100.0
Leybonol LVO 420 Special oil for vacuum pumps Oerlikon Leybold L 420 01  1 Liter picturePROFLAV MOUTHGUARD MATERIAL HENRY SCHEIN DENTAL LAB VACUUM FORMING THERMOFORMING
$69.99
PROFLAV MOUTHGUARD MATERIAL HENRY SCHEIN DENTAL LAB VACUUM FORMING THERMOFORMING picturevacuum powered dustless turbo drywall sander
$169.96
vacuum powered dustless turbo drywall sander pictureMKS Stainless Steel Vacuum Flexible Bellows Hose, Thick Wall, KF40, 10"L
$79.0
MKS Stainless Steel Vacuum Flexible Bellows Hose, Thick Wall,  KF40, 10UltraSource Vacuum Chamber Pouches, 3 mil, 12" x 18" Pack of 500
$111.8
UltraSource Vacuum Chamber Pouches, 3 mil, 12






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