求助:读写文件时出现的问题
1.写文件时语句如下:
OutputConnection connection = (OutputConnection)
Connector.open( "file://c:/myfile.txt;append=true ", Connector.WRITE );
运行时会抛出
java.lang.IllegalArgumentException异常,请问该如何解决?
2.读文件界面:is it ok to read your files?
按下yes键,运行后出现警告:
Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.
请问这是怎么回事啊??????????
------解决方案--------------------1.不知道你这个OutputConnection是你自己封装的类还是什么东西,但是要做写的操作我只是见过在这样的:
FileConnection fc = ( FileConnection ) Connector.open( "file:///... ",Connector.READ_WRITE);
DataOutputStream out = new DataOutputStream( fc.openOutputStream() );
2.这多半是因为你把操作文件的代码放到了commandAction中,所以导致可能产生线程死锁
------解决方案--------------------这是警告你会出现死锁或者阻塞。你需要开个新线程