日期:2014-05-20  浏览次数:20696 次

J2ME怎么写入txt
WTK2.5模拟器应该是自带JRS75协议的吧,是吗?

我用的下面的代码写入不行啊
Java code
try{
            FileConnection fc = (FileConnection)Connector.open("file://localhost/d:/b.txt",Connector.READ_WRITE);
                
            byte[] b="Hello World".getBytes();        
            
            OutputStream os = fc.openOutputStream();       
            
            os.write(b,0,b.length);
            
            System.out.println("写入成功");
            
        }catch (Exception e) {
            // TODO: handle exception
        }


应该是这句有问题:OutputStream os = fc.openOutputStream();
要怎么改?

再问一个,Connector.open(),如果要定位在项目的默认目录下,参数是怎样的?测试过这个:/b.txt,不是这个啊!

------解决方案--------------------
http://topic.csdn.net/u/20070828/12/08a4ba4f-7a1c-4fb0-a44d-bdba992f1862.html