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

 
/**
  * 把字符串追加到文本里去
  * 
  * @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();
   }
}

你可能感兴趣的:(String,测试,File,dos,手机,j2me)