gpt4 book ai didi

java - j2me 中文件处理的安全异常

转载 作者:行者123 更新时间:2023-12-01 05:56:09 25 4
gpt4 key购买 nike

我正在尝试生成日志文件。

static String fname="file:///c:/logfile.txt;append=true";
fc = (FileConnection) Connector.open(fname, Connector.WRITE);
if (fc.exists()) {
// file exists, open at EOF.
offset = fc.fileSize();
os = fc.openOutputStream(offset);
} else {
// file does not exist, create and open.
fc.create();
os = fc.openOutputStream();
}

出现以下异常

java.lang.SecurityException: Access denied
at com.symbian.midp.io.protocol.file.FileConnectionImpl.open(FileConnectionImpl.java:71)
at com.symbian.midp.io.protocol.file.Protocol.openConnection(Protocol.java:40)
at com.symbian.gcf.ProtocolBase.openConnection(), bci=159
at com.symbian.gcf.GCFConnector.open(), bci=237
at com.symbian.j2me.midp.legacy.LegacyConnectionFactory.open(LegacyConnectionFactory.java:35)
at com.symbian.j2me.midp.runtimeV2.ConnectionService.open(), bci=8
at javax.microedition.io.Connector.open(), bci=6
at javax.microedition.io.Connector.open(Connector.java:48)
at Symbian.LogFile.FileOpen(LogFile.java:27)
at Symbian.Symbian.startApp(Symbian.java:216)
at javax.microedition.midlet.MIDletInvoker.invokeStartApp(MIDletInvoker.java:30)
at com.symbian.j2me.midp.runtimeV2.Application.startAction(Application.java:458)
at com.symbian.j2me.midp.runtimeV2.Application.startRequest(Application.java:413)
at com.symbian.j2me.midp.runtimeV2.Application.event(Application.java:264)
at com.symbian.j2me.midp.runtimeV2.ApplicationEvent.dispatch(ApplicationEvent.java:90)
at com.symbian.j2me.midp.runtimeV2.ApplicationThread.run(ApplicationThread.java:30)

访问被拒绝

最佳答案

改变

static String fname="file:///c:/logfile.txt;append=true";

static String fname="file:///c:/logfile.txt";

关于java - j2me 中文件处理的安全异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2887591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com