thufir

Untitled

Aug 29th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. package teln;
  2.  
  3. import static java.lang.System.out;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6.  
  7. public class StreamReader {
  8.  
  9. private StreamReader() {
  10. }
  11.  
  12. StreamReader(InputStream inputStream) throws IOException {
  13. printEachLine(inputStream);
  14. }
  15.  
  16. private void printEachLine(InputStream inputStream) throws IOException {
  17. int foo = 0;
  18. char ch = 0;
  19. StringBuilder sb = new StringBuilder();
  20. out.println("lines..");
  21. boolean isEOL = false; //err, need to set this or get rid of it
  22. do {
  23. foo = inputStream.read();
  24. ch = (char) foo;
  25. //out.print(foo);
  26. sb.append(ch);
  27. if ((ch == 10)) {
  28. out.print(sb);
  29. sb = new StringBuilder();
  30. foo = inputStream.read();
  31. ch = (char) foo;
  32. sb.append(ch);
  33. if (ch != 13) {
  34. while ((255 > ch) && (ch >= 0)) {
  35. sb = new StringBuilder();
  36. foo = inputStream.read();
  37. ch = (char) foo;
  38. sb.append(ch);
  39. out.print(sb);
  40. }
  41. }
  42. sb.append(ch);
  43. }
  44.  
  45. } while (!isEOL);
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment