This is working fine for me, the file exists, so it is not created, instead, it is read, and system out'd with a little extra padding at end
Code:
public void createFile()
{
try {
FileConnection filecon = (FileConnection)
Connector.open("file:///root1/readme", Connector.READ_WRITE);
// Always check whether the file or directory exists.
// Create the file if it doesn't exist.
if(!filecon.exists()) {
filecon.mkdir();
System.out.println("File Created");
}
else
{
System.out.println("File NOT created, it exists");
InputStream fis = filecon.openInputStream();
byte[] b = new byte[1024];
int length = fis.read(b, 0, 1024);
fis.close();
System.out.println("File Data:");
System.out.println(new String(b));
}
filecon.close();
} catch(Exception ioe) {System.out.println(ioe);
}
}