BlackBerry logger
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 = (FileCon开发者_如何学编程nection)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) { }
}
}
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.
From within the simulator you can also go to Media, click the menu button, select Explore and browse to your file.
Another option is to set your simulator to save the content to a chosen location on the file system: in Eclipse go to Run -> Debug Configurations -> Simulator tab -> Memory tab. Check the "Use PC file system for SD Card files" option and browse to your preferred location. I found this to be very convenient.
Hope this helps :)
精彩评论