J2ME为什么不能创建递归目录创建? [英] Why isn't J2ME able to create recursive directory creation?

查看:99
本文介绍了J2ME为什么不能创建递归目录创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建recursive目录(例如:Connector.open("file:///Phone:/folder_1/folder_2/", Connector.READ_WRITE);).问题是没有明确提及两个folders,这里是folder_1和folder_2,但是方法中只提供了一个String参数.例如:

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);
...
}

在运行时不会创建两个文件夹!因此,我必须分别创建两个FileConnection才能创建两个文件夹!那么,为什么J2ME无法创建recursive目录?

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 ?

推荐答案

您也可以尝试一些新方法.您可以使您的方法递归,现在传递一个向量&整数参数,vector的元素将是您要创建的目录的列表,而整数将指定方法应将其调用为self的时间.

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.

即用于folder_1& folder_2,您可以将参数作为method_name(folderVector,2)传递.这里folderVector变量包含两个String元素,作为folder_1&文件夹_2.现在,您需要递归地调用您的方法,使,每当第二个参数减小1时其值减小.运行此方法,直到大于零为止.

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.

这篇关于J2ME为什么不能创建递归目录创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆