您的位置:首页 > 其它

J2ME程序在手机上测试记录下调试信息

2011-12-26 13:20 507 查看
/**
  * 把字符串追加到文本里去
  * 
  * @param str
  */
 public void writeStringToFile(String str) {

   FileConnection fc;
   try {
    String file = "file:///c:/barcode.txt";
    fc = (FileConnection) Connector.open(file01, Connector.READ_WRITE);
    if (!fc.exists()) {
     fc.create();
    }
    OutputStream os = fc.openOutputStream(fc.fileSize());
    DataOutputStream dos = new
    DataOutputStream(os);
    dos.write((str).getBytes("utf-8"));
    dos.write("\r\n".getBytes());
    os.close();
    dos.close();
    fc.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: