用fileconnection写文件的问题
时间:2008-08-27 23:01:39
来源:论坛整理 作者: 编辑:chinaitzhe
String s;
FileConnection fc;
Image meinv;
InputStream is;
try {
fc=(FileConnection) Connector.open("file://localhost/E:/test.txt", Connector.READ_WRITE);
s="你好,这是我的第一个测试";
if(!fc.exists())
fc.create();
fc.openOutputStream().write(s.getBytes(),0,s.getBytes().length);
fc.close();
fc=(FileConnection) Connector.open("file://localhost/E:/meinv.jpg", Connector.READ_WRITE);
if(!fc.exists())
fc.create();
byte b[]=new byte[10000];
is=this.getClass().getResourceAsStream("meinv.jpg");
is.close();
meinv=Image.createImage(is);
is.read(b, 0, b.length);
fc.openOutputStream().write(b,0,b.length);
fc.close();
} catch (IOException e){
e.printStackTrace();
}
然后我打开手机存储卡上的test.txt,发现什么里面一个字符也没有,文件大小是0KB,我打开meinv.jpg,提示无法打开图像,图像大小是0KB,求求高手这是怎么一回事啊?
网友回复:flush() 一下
网友回复:同楼上
网友回复:楼主老是不结贴,哼^^^
关键字:文件,问题,
下一篇:下面没有链接了











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面