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