File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes Unable to create/find new 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/find new file" Watch "Unable to create/find new file" New topic

Unable to create/find new file

Ritesh Chopade

Joined: Oct 22, 2008
Posts: 8
I am new to J2ME. I am developing application to download file from one mobile to another through bluetooth connection. I am working using J2ME wireless toolkit.
I receive data through bluetooth connection(from slave to master). At master device I have to create new file(if not exists) & write the data(from slave) to file.
My code works fine(without exception), but once code execute fine I am not able to see the file at root location in j2me wireless toolkit(emulator) using default color phone.
My root folder is root1. My code is as follows,

final byte[] data = "It is my just a test data".getBytes(); //Data which is comes from another blutooth device
final String fName = "file:///root1/test.txt";
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){

Please help me.
Thanks in advance.....
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Different phones do filesystems in different ways. There's no universal standard, and as far as I know, even the existence of a filesytem is optional.

You might try doing this:

File myDirectory = new File(".");

Then display myDirectory.getAbsolutePath();

That will show you where you're starting from and how the filenames are formed on that device.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Unable to create/find new file
jQuery in Action, 3rd edition