Guest User

Untitled

a guest
Aug 21st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. Filter \n character from inputstream
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <response processor="header" callback="comheader">
  4. <properties>
  5. <timezone>Asia%2FBeirut</timezone>
  6. <rawoffset>7200000</rawoffset>
  7. <to_date>1319256000000</to_date>
  8. <dstrawoffset>10800000</dstrawoffset>
  9. </properties>
  10. </response>
  11. n
  12. <event type="progress" time="1317788744214">
  13. <param key="callback">todayactions</param>
  14. <param key="percent">10</param>
  15. <param key="msg">MAPPING</param>
  16. </event>
  17. <event type="progress" time="1317788744216">
  18. <param key="callback">todayactions</param>
  19. <param key="percent">20</param><param key="msg">MAPPING</param>
  20. </event>
  21. n
  22. <?xml version="1.0" encoding="UTF-8"?>
  23. <response processor="header" callback="comheader">
  24. <properties>
  25. <timezone>Asia%2FBeirut</timezone>
  26. <rawoffset>7200000</rawoffset>
  27. <to_date>1319256000000</to_date>
  28. <dstrawoffset>10800000</dstrawoffset>
  29. </properties>
  30. </response>
  31.  
  32. public class FilterStreamReader extends InputStreamReader {
  33. public FilterStreamReader(InputStream in, String enc)
  34. throws UnsupportedEncodingException {
  35. super(in, enc);
  36. }
  37.  
  38. @Override
  39. public int read(char[] cbuf, int off, int len) throws IOException {
  40. int read = super.read(cbuf, off, len);
  41. Log.e("Reader",Character.toString((char)read));
  42. if (read == -1) {
  43. return -1;
  44. }
  45.  
  46. int pos = off - 1;
  47. for (int readPos = off; readPos < off + read; readPos++) {
  48. if (read == 'n') {
  49. pos++;
  50. } else {
  51. continue;
  52. }
  53. if (pos < readPos) {
  54. cbuf[pos] = cbuf[readPos];
  55. }
  56. }
  57. return pos - off + 1;
  58. }
Add Comment
Please, Sign In to add comment