2013-04-05 54 views
0

我想通過代碼在j2me中創建一個文件夾和圖像。我能夠在模擬器中創建一個圖像文件,但是當我嘗試在移動設備(諾基亞2700)上運行該代碼時...它給出了例外。我的代碼folloes .....無法通過j2me中的代碼創建文件夾和文件

Enumeration e = FileSystemRegistry.listRoots(); 
       String root = null; 
       while (e.hasMoreElements()) { 
       root = (String) e.nextElement(); 
       break; 
      } 

String newFilePath = "file:///"+root+fileName[i]; 

FileConnection fileConnection = (FileConnection) Connector.open(newFilePath, 
Connector.READ_WRITE); 

       if(!fileConnection.exists()) 
        fileConnection.create(); 

       else if(fileConnection.fileSize() == mediaSize){ 
        fileConnection.close(); 
        continue; 
       } 

我應該在前面創造一個圖像文件確實存在的文件夾,或者如果可能的話,我怎麼可能創造在J2ME中的文件夾。

回答

0

某些手機僅允許在根的某些子文件夾中創建文件夾和文件。您可能不允許在root 2700上創建文件夾或文件。

通常,您必須轉到這些電話上的「其他」文件夾。因此,嘗試這兩個爲路徑和文件名中的一個:

file:///c:/other/myfolder/myimage.jpg 
file:///e:/other/myfolder/myimage.jpg 

根據您是否要保存到手機內存(C盤)或存儲卡(E盤)。

相關問題