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

SenSym SSX 100G Pressure Transducer NEW
$79.0
SenSym SSX 100G Pressure Transducer NEW pictureGEMS Series 2200 Pressure Transducer Type 2200BG6F00223EA VAC-45 PSIG, 4-20 MA
$99.0
GEMS Series 2200 Pressure Transducer Type 2200BG6F00223EA  VAC-45 PSIG,  4-20 MA pictureSiemens ACUSON 4C1 Probe Ultrasound Transducer
$49.0
Siemens ACUSON 4C1 Probe Ultrasound Transducer pictureSiemens Acuson 7 Needle Guide L7 Ultrasound Linear Array Transducer Probe
$50.0
Siemens Acuson 7 Needle Guide L7 Ultrasound Linear Array Transducer Probe picturePortable Ultrasound Scanner Machine system + Linear Transducer +3D Software
$1188.42
Portable Ultrasound Scanner Machine system + Linear Transducer +3D Software  picture






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