Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. String path = Environment.getExternalStorageDirectory().toString();
  2. File file = null;
  3. String newline = "\n";
  4.  
  5. file = new File(path + "/Peer 2 Peer/Saved txt files", FILE_NAME);
  6.  
  7. FileOutputStream stream;
  8. try {
  9. stream = new FileOutputStream(file, false);
  10. for (int i = 0; i < chatFullList.size(); i++) {
  11. // pw.write("It is here");
  12. String l = chatFullList.get(i).getIp().concat(" : ");
  13. stream.write(l.getBytes());
  14. stream.write(chatFullList.get(i).getMsg().getBytes());
  15. stream.write(newline.getBytes());
  16. Log.d(TAG, chatFullList.get(i).getIp() + " : " + chatFullList.get(i).getMsg() + "\n"); }
  17. stream.close();
  18. } catch (FileNotFoundException e) {
  19. e.printStackTrace();
  20. } catch (IOException e) {
  21. e.printStackTrace();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement