int start=0,flag=1;
            long size=blobInfo.getSize(),fetched=0,fetch;
            byte temp[] = null;

            while(fetched<size){
               if(size-fetched>MAX_BLOB_FETCH_SIZE)
                    fetch=MAX_BLOB_FETCH_SIZE;
               else
                    fetch=size-fetched;

               temp=blobstoreService.fetchData(blobKey,fetched,fetch );

               fetched+=fetch;
               out.println(temp);
        }


我试图使用上面的代码打印上载的文本文件的数据,但似乎不起作用。

最佳答案

我知道了。


while(blobInfo.getSize()> positionInBlob){
long endIndex = Math.min(blobInfo.getSize(),positionInBlob + chunkSize);
chunk = blobstoreService.fetchData(blobKey,positionInBlob,endIndex);
positionInBlob + = chunk.length;

         for(int j=0;j<chunk.length;j++){
             int c=chunk[j];
             out.println((char)c);
         }

     }

10-08 18:02