Writes all the buffers to the output stream
()
| 95 | /** Writes all the buffers to the output stream |
| 96 | */ |
| 97 | @Override |
| 98 | public void run() { |
| 99 | try{ |
| 100 | Iterator<byte[]> buffIter = buffer.iterator(); |
| 101 | while(buffIter.hasNext()){ |
| 102 | byte currentBuff[] = buffIter.next(); |
| 103 | if(buffIter.hasNext()) { |
| 104 | // is not the last buffer |
| 105 | outputStream.write(currentBuff,0,buffSize); |
| 106 | } else { |
| 107 | // is the last buffer |
| 108 | // currentBuff[lastOffset] = '\u001a'; |
| 109 | outputStream.write(currentBuff,0,lastOffset); |
| 110 | } |
| 111 | }// while(buffIter.hasNext()) |
| 112 | |
| 113 | outputStream.flush(); |
| 114 | outputStream.close(); |
| 115 | } catch(IOException ioe) { |
| 116 | throw new RuntimeException(ioe.toString()); |
| 117 | // ioe.printStackTrace(Err.getPrintWriter()); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | |
| 122 | /** I need a thread to write the object so I can read it in an buffer |