This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

bluetooth connction blocks file creation  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application, I have to establish the connection to server mobile(slave) through bluetooth. but once I establish connection to server mobile, I am unable to create new file.
But the file is created before connection establishment. I have set all API permissions also.
If anyone have solution, please help me its too urgent.
 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should explain more clearer:

1 Do you use only one thread for everything? If so, and after you connect to server and waiting for IO, that blocks the thread so you won't be able to create a new file

2 Do you mean RMS data or local file via JSR 75 File Connection API?

3 What error message/exception do you get? Can you try to catch some exceptions and post the results?
 
Ritesh Chopade
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi HaoZhe,
I use different thread for bluetooth connection & file creation.
And I am talking about local file via JSR 75 File Connection API.
I never get any error/exception.

The following is the code fragment of my application. The code works fine event the exists method of File Connection class return true
(i.e:- file created), but I am unable to find it at file system.

The code fragment as,

final byte[] data = "It is my just a test data".getBytes(); //It is the data which is comes from another bluetooth device
final String fName = "file:///root1/test.txt"; //The file I want to create at my file system(i.e:- root1 folder in my file system)
new Thread(new Runnable() {

public void run() {
try{
FileConnection fc = (FileConnection) Connector.open(fName, Connector.WRITE);
System.out.println("fc.exists()(Before) : " + fc.exists() ); //It prints "fc.exists()(Before) : false"
if( !fc.exists() ){
fc.create();
System.out.println("fc.exists()(After) : " + fc.exists() ); //It prints "fc.exists()(After) : true"
OutputStream fout = fc.openOutputStream();
fout.write(data);
fout.close();
}
fc.close();
}catch(IOException ex){
ex.printStackTrace();
}
}
}).start()


And for more information you check my yesterday's post Unable to create file
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!