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

Computer Analog Instrument Number Readout German 24 Volt FS066 National Lab Lot
$100.0
Computer Analog Instrument Number Readout German 24 Volt FS066 National Lab Lot  pictureMeasurement Computing PCI-DDA08/16 8-channel 16-bit analog output 48 digital I/O
$100.0
Measurement Computing PCI-DDA08/16 8-channel 16-bit analog output 48 digital I/O pictureComputer Boards CIO-DAS802/16 Analog Input and Digital I/O
$199.99
Computer Boards CIO-DAS802/16 Analog Input and Digital I/O pictureAllen Bradley ANALOG PLC Trainer RSLOGIX Computer with Lessons and Software
$1499.0
Allen Bradley ANALOG PLC Trainer RSLOGIX Computer with Lessons and Software  pictureCOMPUTER BOARDS, INC Analog Input Board CIO-DAS48-PGA
$299.99
COMPUTER BOARDS, INC Analog Input Board CIO-DAS48-PGA picture






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