RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

J2ME程序操作文件系统

来源: 作者: 时间:2007-08-14 点击:

     */
    OutputStream out 
= fc.openOutputStream();
    
byte[] b = "contents".getBytes("UTF-8");
    out.write(b);
    out.flush();
    out.close();
   }
else{
    
/**
     * 打开输入流,读取文件中的内容
     * 要求文件打开方式为可读
     
*/

    InputStream dis 
= fc.openInputStream();
    
    
/**
     * 获取文件大小
     
*/

    
int size = (int)fc.fileSize();
    
    
byte[] bytes = new byte[size];
    dis.read(bytes, 
0, bytes.length);
    String str 
= new String(bytes, "UTF-8");
    tb 
= new TextBox("", str, 200, TextField.ANY);
    dis.close();
   }

   fc.close();

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
Google Adsense
相关文章