看板 AndroidDev 關於我們 聯絡資訊
我現在有個可以連續解碼QR Code的程式 以及一個連續播放QR Code的程式 但是解碼的速度跟不上編碼速度 所以會有一些遺漏 我想生成一個txt檔 把有成功生成的部分製成一個txt檔 以下是那部分的程式碼 public void onCodeScanned(String data) { txv1.setText(String.valueOf(data)); Toast.makeText(MainActivity.this, data,Toast.LENGTH_LONG).show(); try { File file = new File(getExternalFilesDir (Environment.DIRECTORY_DOWNLOADS), "QR Code.txt"); FileOutputStream fos = new FileOutputStream(file); fos.write(data.getBytes()); fos.close(); } catch (IOException e) {} } 但是生成出來的txt檔,只會有最後一個解碼出來的內容(中間其它的都沒有) 請問要如何改呢? 感激~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.123.115.137 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1463660050.A.EA3.html
dmggd: 輸出到固定檔案,不是會一直被覆蓋嗎? 05/19 23:04
cooper6334: 分別寫檔或append,new FileOutputStream(file,true) 05/20 07:33
puppyulove: 感激 了解了 05/20 13:23
boolean append=ture; FileOutputStream fos = new FileOutputStream(file,append) 就行了 ; ※ 編輯: puppyulove (140.123.115.137), 05/20/2016 13:26:35