Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to create file  RSS feed

Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to download file from server mobile(through bluetooth), I receive data properly from server to client mobile. But once I get data, I have to create a file(in write mode)
at my client mobile to stored the data from server. But I am unable to create file at my client, code doesn't give me error/exception(it works fine) but I can't find the file at file system
(i.e:- root folder(in filesystem folder) at my J2ME wireless toolkit 2.5). I have specified the code below to create file.

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() {
FileConnection fc = (FileConnection), Connector.WRITE);
System.out.println("fc.exists()(Before) : " + fc.exists() ); //It prints "fc.exists()(Before) : false"
if( !fc.exists() ){
System.out.println("fc.exists()(After) : " + fc.exists() ); //It prints "fc.exists()(After) : true"
OutputStream fout = fc.openOutputStream();
}catch(IOException ex){

I observe one thing here that the above code works fine if I use it outside of my bluetooth interaction & data access code(i.e:- input/output streams & server connections).
Any help will be appreciated
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!