日期:2014-05-20  浏览次数:20661 次

j2me的moto开发,文件浏览模块无法连接到文件,无法创建文件
似乎C:\Program   Files\Motorola\Motorola   Java   ME   SDK   v6.2   for   Linux   OS   Products\EmulatorM.3\devroot目录是模拟器的根目录,为了与手机真实目录相同,于是此目录下手动创建了文件夹phone和SD两目录,并在SD目录下创建了test.txt文件.结果执行下面代码时连接不到文件:
try   {
            fconn=(FileConnection)   Connector.open( "file://localhost/SD/test.txt ");
            if   (!fconn.exists())   {
                Alert   alert   =   new   Alert( "Error ",   "file   does   not   exist ",   null,
                                                                AlertType.ERROR);
                alert.setTimeout(Alert.FOREVER);
                dis.setCurrent(alert);
                mess   =   mess.concat( "file   does   not   exist; ");
                fconn.create();
            }
}
catch(exception   e){System.out.println(e.toString());}
模拟器上跳出Alert:file   does   not   exist手机上却可以正常找到文件建立连接.

fconn.create();函数也未成功.
是不是调用Connector.open函数时的参数路径不对????
如果是,那么该怎么设置模拟器的路径

------解决方案--------------------
路径错了file:///SD/test.txt这样试试