views:

20

answers:

2

I am writing a text file on the BlackBerry simulator using the following code. My data is written successfully to the file but I am not able to find my file. Where can I can find my file on the simulator?

public static void debug() { 
    OutputStream os = null;
    FileConnection fc = null;
    try { 
        String data = "Hello This is Yogesh working on blackberry";

        Dialog.alert("TEST_1");
        fc = (FileConnection)Connector.open("file:///SDCard/test.txt",Connector.READ_WRITE);
        //fc = (FileConnection)Connector.open("file:///SDCard/BlackBerry/pictures/test.txt",Connector.READ_WRITE);
        Dialog.alert("TEST_2");
        //FileConnection fc = (FileConnection)Connector.open(System.getProperty("file:///SDCard/"+"test.txt"),Connector.READ_WRITE);
        Dialog.alert("TEST_3");
        if(!fc.exists()) {
            Dialog.alert("TEST_31");
            fc.create();
        }
        Dialog.alert("TEST_4");
        os = fc.openOutputStream();
        Dialog.alert("TEST_5");
        os.write(data.getBytes());
        Dialog.alert("TEST_6");
        Dialog.alert("Data written successfully...!!!");
    } catch(Exception e) {
        Dialog.alert("Exception in writing logs :"+e);
    } finally {
        if(os != null) {
        try {
            os.close();
        } catch(Exception e) { }
    }
    if(fc != null) {
        try {
            fc.close();
        } catch(Exception e) { }
    }
}
A: 

Within the simulator, if you open the Files application, in the 'Applications' folder, you can navigate through the SDCard files, by selecting File Folders, and then Media Card.

Michael Donohue