2010-10-30 74 views
0

我正在使用以下代碼在BlackBerry模擬器上編寫文本文件。我的數據已成功寫入文件,但我無法找到我的文件。我在哪裏可以在模擬器上找到我的文件?BlackBerry記錄器

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) { } 
    } 
} 

回答

0

在模擬器中,如果在「應用程序」文件夾中打開文件應用程序,您可以通過SD卡的文件瀏覽,選擇文件夾,然後媒體卡。

0

從模擬器中,你也可以去媒體,點擊菜單鍵,選擇探索並瀏覽到您的文件。

另一種選擇是設置模擬器的內容保存到文件系統上的選定位置:在Eclipse中去運行 - >調試配置 - >模擬器標籤- >內存標籤。檢查「使用SD卡文件的PC文件系統」選項並瀏覽到您的首選位置。我發現這很方便。

希望這會有所幫助:)