BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-11-2008, 05:31 AM   #1 (permalink)
New Member
 
Join Date: Sep 2008
Location: Málaga, Spain
Model: 8310
PIN: N/A
Carrier: dont know
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question Bluetooth FTP server download

Please Login to Remove!

Hello, I am trying to develop an app that downloads a file from a Bluetooth FTP server. If I use this code to dowload a file-list works fine, but if I use the same code to download a real file it doesn't. I have tried with text plain, image, video (mp4 and 3gp) and audio with the same result. If I install my app in a Nokia (N95) or a Motorola (K3) works perfect, but I can't make it work on my Blackberry 8310

This is the code to get the InputStream:
PHP Code:
    public InputStream getFileInputStream(ClientSession connOperation opString stFileString stTypethrows IOException {
        
InputStream inputStream null;
        
bytexxx91;xxx93; FBUUID = {(byte0xF9, (byte0xEC, (byte0x7B, (byte0xC4, (byte0x95
                  (
byte0x3C, (byte0x11, (byte0xD2, (byte0x98, (byte0x4E, (byte0x52, (byte0x54
                  (
byte0x00, (byte0xDC, (byte0x9E, (byte0x09 };
        
String file stFile;
        
String type stType;
        if (
file==nullfile="";
        if (
type==nulltype="";
        
//Prepare the headers for the OBEX commands
        
HeaderSet header conn.createHeaderSet();
        
header.setHeader(HeaderSet.TARGETFBUUID);
        
//Send OBEX Connect
        
HeaderSet response conn.connect(header);
        
//In order to go the desired folder the OBEX SETPATH command is beeing used
        //Prepare the header for the SETPATH commad
        
header conn.createHeaderSet();
        
//folder_name is set to the name of the desired folder
        //if left blank the root folder will be used
        
String folder_name "";
        
header.setHeader(HeaderSet.NAMEfolder_name);
        
//Send the SETPATH command
        
HeaderSet result conn.setPath(headerfalsefalse);

        
//Prepare the header for the GET command
        
header conn.createHeaderSet();
        
header.setHeader(HeaderSet.NAMEfile);
        
header.setHeader(HeaderSet.TYPEtype);
        
op conn.get(header);
        
//The selected file will be send to the operation's input stream
        
inputStream op.openInputStream();
        return 
inputStream;
    } 
And the call:
PHP Code:
InputStream in getFileInputStream(connop"text.txt""text/plain"); 
The same call that works perfect for file-list (in BlackBerry too):
PHP Code:
InputStream in getFileInputStream(connop"""x-obex/folder-listing"); 
This call produces an xml file that can be read perfectly by any phone.

I forgot to say that the problem in the BlackBerry is an EOFException while reading the first byte, no -1 is returned to indicate the end of file but an EOFException.

Any help is much appreciated!
Regards

Last edited by apokalchys : 11-11-2008 at 05:35 AM. Reason: I Forgot one thing
Offline  
Old 11-14-2008, 04:53 AM   #2 (permalink)
New Member
 
Join Date: Sep 2008
Location: Málaga, Spain
Model: 8310
PIN: N/A
Carrier: dont know
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

More data:

I've seen that the problem is that the BlackBerry remains waiting for data (reads 0). If I use an InputStreamReader for reading an XML file everything works fine, but if I use an InputStream the problems appear. This is the code that I use to read:

PHP Code:
// This should in reality read all incoming data
String encoding System.getProperty("microedition.encoding");
testForm.append("Encoding: "+encoding);
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
byte xxx91;xxx93; buf = new byte xxx91;256xxx93;;
int i 0;
while ( (
in.read(buf)) > -) {    
testForm.append(i+";");
    
baos.write(buf0i);              
}                                       
baos.flush();                           
byte xxx91;xxx93; result baos.toByteArray();    
baos.close();                           
String utfString = new String(result"UTF-8"); 
If I replace "UTF-8" for encoding I get the same result because the app remains freezed reading 0.The same code in a Nokia N95 gets the codes 256, 256, 97 and finally the XML file. In BlackBerry gets 256, 256, 97 and infinite 0's.

Is there any way to force reading the file?
Offline  
Old 11-18-2008, 07:23 AM   #3 (permalink)
New Member
 
Join Date: Sep 2008
Location: Málaga, Spain
Model: 8310
PIN: N/A
Carrier: dont know
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solved. The problem was to use >-1 instead of !=-1

Last edited by apokalchys : 11-18-2008 at 07:25 AM.
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





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