Package org.simpleframework.http.core

Examples of org.simpleframework.http.core.Chunker


  }
 
  public void testChunks(int chunkSize, int dribble, int entitySize) throws Exception {    
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ByteArrayOutputStream plain = new ByteArrayOutputStream();
      Chunker encode = new Chunker(out);
      StringBuffer buf = new StringBuffer();
      int fill = 0;
     
      for(int i = 0, line = 0; i < entitySize; i++) {
         String text = "["+String.valueOf(i)+"]";
        
         if(fill >= chunkSize) {
            encode.write(buf.toString().getBytes("UTF-8"));
            plain.write(buf.toString().getBytes("UTF-8"));
            buf.setLength(0);
            fill = 0;           
            line = 0;
         }        
         line += text.length();
         fill += text.length();
         buf.append(text);
        
         if(line >= 48) {
            buf.append("\n");
            fill++;
            line = 0;
         }

      }
      if(buf.length() > 0) {
         encode.write(buf.toString().getBytes("UTF-8"));
         plain.write(buf.toString().getBytes("UTF-8"));
      }
      buffer = new ArrayAllocator().allocate(); // N.B clear previous buffer
      encode.close();
      byte[] data = out.toByteArray();
      byte[] plainText = plain.toByteArray();
      //System.out.println(">>"+new String(data, 0, data.length, "UTF-8")+"<<");
      //System.out.println("}}"+new String(plainText, 0, plainText.length,"UTF-8")+"{{");
      DribbleCursor cursor = new DribbleCursor(new StreamCursor(new ByteArrayInputStream(data)), dribble);
View Full Code Here

TOP

Related Classes of org.simpleframework.http.core.Chunker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.