Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. private String readLine (InputStream in)
  2. {
  3. StringBuffer line = new StringBuffer("");
  4. int c=0;
  5.  
  6. try
  7. {
  8. in.mark(1);
  9. if (in.read() == -1)
  10. return null;
  11. else
  12. in.reset();
  13.  
  14. while ((c = in.read()) >= 0)
  15. {
  16. if ((c == 0) || (c == 10) || (c == 13))
  17. break;
  18. else
  19. line.append((char)c);
  20. }
  21.  
  22. if (c == 13)
  23. {
  24. in.mark(1);
  25. if (in.read() != 10)
  26. in.reset();
  27. }
  28. } catch (Exception e) {}
  29.  
  30. return line.toString();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement