public final static Block[] getBlocksFromOutputStream( OutputStream bbuf, int blen, int type )
	{
		int SIZE = 0;
		switch( type )
		{
			case Block.BIG:
				SIZE = 512;
				break;
			case Block.SMALL:
				SIZE = 64;
		}
		int sz = LEOFile.getSizeInBlocks( blen, SIZE );

		if( bbuf == null )
		{
			return null;
		}
		// int len = (blen-3) / SIZE;
		int len = (blen) / SIZE;
		int pos = 0;
		int sizeDiff = 0;
		int size = 0;

		if( (len * SIZE) < blen )
		{
			len++;
			sizeDiff = (len * SIZE) - blen;
		}
		Block[] blockarr = new Block[len];
		ByteArrayInputStream ins = null;

		// KSC: made a bit simpler upon padding situations ...
		// get ALL blockVect (512 byte chunks of file)
		for( int i = 0; i < len; i++ )
		{
			Block bbd = getPrototypeBlock( type );
			byte[] bb = bbd.getBytes();
			int filepos = i * SIZE;
			if( type == Block.SMALL )    // smallblocks don't need file offset as they are allocated differently than bigblocks
			{
				filepos = 0;
			}

			size = SIZE;
			// make simpler:
			if( (blen - pos) < size )
			{
				size = (blen - pos);
			}
			ins.read( bb, pos, size );
			bbd.init( ByteBuffer.wrap( bb ), i, filepos );
			pos += SIZE;
			blockarr[i] = bbd;
		}
		return blockarr;
	}