开发者

security exception in file handling in j2me

开发者 https://www.devze.com 2022-12-31 00:58 出处:网络
i am trying to generate a logfile. static String fname=\"file:///c:/logfile.txt;append=true\"; fc = (FileConnection) Connector.open(fname, Connector.WRITE);

i am trying to generate a logfile.

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

getting tthe following exception

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)
开发者_StackOverflow

Access denied


Change

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

to

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

精彩评论

暂无评论...
验证码 换一张
取 消