File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Unable to create file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Unable to create file" Watch "Unable to create file" New topic
Author

Unable to create file

Ritesh Chopade
Greenhorn

Joined: Oct 22, 2008
Posts: 8
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to create file
 
Similar Threads
bluetooth connction blocks file creation
HttpConnection question ...
How to create a Text File in Nokia 6630
Unable to create/find new file
Application not authorized to access the restricted api