Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public void appendLog(String text)
  2. {
  3. File logFile = new File("sdcard/log.file");
  4. if (!logFile.exists())
  5. {
  6. try
  7. {
  8. logFile.createNewFile();
  9. }
  10. catch (IOException e)
  11. {
  12. // TODO Auto-generated catch block
  13. e.printStackTrace();
  14. }
  15. }
  16. try
  17. {
  18. //BufferedWriter for performance, true to set append to file flag
  19. BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
  20. buf.append(text);
  21. buf.newLine();
  22. buf.close();
  23. }
  24. catch (IOException e)
  25. {
  26. // TODO Auto-generated catch block
  27. e.printStackTrace();
  28. }
  29. }
Add Comment
Please, Sign In to add comment