Hello,
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() {
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();
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