Why isn't J2ME able to create recursive directory creation?

≡放荡痞女 提交于 2019-12-02 18:07:48

问题


I want to create recursive directories ( for example : Connector.open("file:///Phone:/folder_1/folder_2/", Connector.READ_WRITE); ). The problem is that the two folders , here folder_1 and folder_2, are not mentioned explicitly but instead there is only one String parameter provided from a method. For example :

private void myMethod(String path) 
{
  fcDir = (FileConnection) Connector.open("file:///Phone:/"+path+"/", Connector.READ_WRITE);
...
}

And in runtime the two folders are not created ! So I must create separately two FileConnection in order to create the two folders ! So why J2ME is not able to make a recursive directory creation ?


回答1:


you may also try thing new way. you can make your method recursive, now pass one vector & integer parameter, vector's element will be the list of directories you want to create and integer will specify the number of time method should call it self.

i.e. for folder_1 & folder_2 you can pass parameter as method_name ( folderVector, 2 ). here folderVector variable contains two String element as folder_1 & folder_2. Now you need to call your method recursively such that , each time second parameter decrements it's value with one down. Run this method till it is greater than zero.

This is the one way you can do it recursively.



来源:https://stackoverflow.com/questions/8007086/why-isnt-j2me-able-to-create-recursive-directory-creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!