将os导入到j2me

0 投票
2 回答
598 浏览
提问于 2025-04-16 07:08

我正在尝试把这段代码写成j2me格式。有没有人知道该怎么做?

谢谢!

import os
if os.path.isfile("c:\\python\\myfolder\\test.txt"):

2 个回答

0

下面的内容可能会对你有帮助。记得手机需要支持JS175哦。

 try {
    fconn = (FileConnection) Connector.open("file:///locaction_of_file", Connector.READ_WRITE);
    if (!fconn.exists()) {
       fconn.create();
  }
} catch (IOException e) {
    e.printStackTrace();
}
1
  1. 先弄明白这一行代码的作用。你可以从Python的os模块的文档开始了解:http://docs.python.org/library/os.path.html

  2. 查阅J2ME的文档,找找有没有类似的函数调用。

撰写回答