English 中文(简体)
j2me filejointion java.io.IOException: 无法获得根基
原标题:j2me fileconnection java.io.IOException: Root is not accessible
 FileConnection c = (FileConnection) Connector.open("file:///c:/myfile.txt",Connector.READ_WRITE);

        if (c.exists())
        {
            System.out.println("exist");

            }
        else {
                System.out.println("no exist");
                c.create();
        }

        OutputStream out = c.openOutputStream();
        PrintStream output = new PrintStream( out );
        output.println( response );
        out.close();
        c.close();

在上述代码I m中,有以下错误:

   no exist
java.io.IOException: Root is not accessible
        at com.sun.midp.io.j2me.file.Protocol.ensureConnected(Protocol.java:1588)
        at com.sun.midp.io.j2me.file.Protocol.ensureOpenAndConnected(Protocol.java:1604)
        at com.sun.midp.io.j2me.file.Protocol.create(Protocol.java:945)
        at hello.Midlet.traverse(Midlet.java:83)
        at hello.Midlet.startApp(Midlet.java:40)
        at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:43)
        at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:374)
        at com.sun.midp.main.Main.runLocalClass(Main.java:466)
        at com.sun.midp.main.Main.main(Main.java:120)

The file file:\c:myfile.txt exists. How do i go about now ?

问题回答

想像你需要确定MIDLet Permissions。

请注意,你可能会在模拟器上进行这项工作,但至少需要签署守则,以找到一种真正的装置。





相关问题
add text in http request string url

ok i made a midlet through which i can connect to server pages and get soem information as response. For example i made a midlet through which i acced url: http://example.com/?u=nepal&t=1 Now i ...

Do I have to do a setSize() on a Vector before using it?

Given private final Vector v = new Vector(); //instance variable the following 3 lines are in an instance method in the same class. 1. int length = v.capacity(); 2. int size = v.size(); ...

Is the situation with Java ME improving?

It seems to be the consensus that developing for Java ME is not as cross platform as you might expect, particularly compared to say java SE, but it is difficult to assess how the situation is evolving....

Privileged operations in netbeans mobility

I m writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background ...

ClassFormatError: 56 while using hessian in j2me

I am trying to use the hessian j2me implementation @ http://hessian.caucho.com/ using java me sdk 3.0. http://hessian.caucho.com/doc/hessian-overview.xtp#Hessian%20Client%20for%20a%20cell-phone ...

热门标签