Merges the local file data fields of the given ZipExtraFields.

@param data an array of ExtraFiles
@return an array of bytes
@since 1.1
17834
public static byte[] mergeLocalFileDataData(List<ZipExtraField> data) {
    int regularExtraFieldCount = data.size();

    int sum = WORD * regularExtraFieldCount;
    for (ZipExtraField element : data) {
      sum += element.getLocalFileDataLength().getValue();
    }

    byte[] result = new byte[sum];
    int start = 0;
    for (ZipExtraField element : data) {
      System.arraycopy(element.getHeaderId().getBytes(),
          0, result, start, 2);
      System.arraycopy(element.getLocalFileDataLength().getBytes(),
          0, result, start + 2, 2);
      byte[] local = element.getLocalFileDataData();
      System.arraycopy(local, 0, result, start + WORD, local.length);
      start += (local.length + WORD);
    }
    return result;
  }
728753
public static DataAttribute createDataAttribute(byte data[]) {
		DataAttribute attribute = new DataAttribute();

		attribute.setData(data);
		return attribute;
	}
290386
public void append(byte[] data) {
        if (data.length >= (this.datas.length - size)) {
            // 扩容
            byte[] newData = new byte[this.datas.length + data.length + this.datas.length / 2];
            System.arraycopy(this.datas, 0, newData, 0, size);
            this.datas = newData;
        }
        System.arraycopy(data, 0, this.datas, size, data.length);
        this.size += data.length;
        modCount++;
    }
62174
public static byte[] calculate(final Data[] data) throws IOException {
        int bitSize = 0;
        for (final Data target : data) {
            bitSize += target.numOfBits;
        }
        int pos = 0;
        final FastBitSet bitSet = new FastBitSet(bitSize);
        for (final Data target : data) {
            int count = 0;
            final byte[] bytes = calculate(target);
            for (final byte b : bytes) {
                byte bits = b;
                for (int j = 0; j < 8; j++) {
                    bitSet.set(pos, (bits & 0x1) == 0x1);
                    pos++;
                    count++;
                    if (count >= target.numOfBits) {
                        break;
                    }
                    bits >>= 1;
                }
            }
        }
        return bitSet.toByteArray();
    }
33172
public static byte[] invert(final byte[] data)	{
		for (int i = data.length; --i >= 0;) {
			data[i] = (byte)~data[i];
		}
		return data;
	}
329483
@Override
	protected byte[] getData(Attributes attributes) {
        byte[] zip = null;
        Map<String, List<String>> filesMap = new HashMap<String, List<String>>();
        Map<String, List<byte[]>> contentsMap = new HashMap<String, List<byte[]>>();

        for (Report report : reports) {
            String folder = report.getName();
            List<String> files = new ArrayList<String>();
            List<byte[]> contents = new ArrayList<byte[]>();

            if (ReportConstants.NEXT.equals(report.getType())) {
                report = NextUtil.restoreImagesName(report);
                NextContent reportContent = (NextContent) report.getContent();
                files.add(reportContent.getNextFile().getName());
                contents.add(reportContent.getNextFile().getDataProvider().getBytes());
                if (reportContent.getImageFiles() != null) {
                    for (JcrFile entry : reportContent.getImageFiles()) {
                        files.add(entry.getName());
                        contents.add(entry.getDataProvider().getBytes());
                    }
                }
				if (reportContent.getTemplateFile() != null) {
					files.add(reportContent.getTemplateFile().getName());
					contents.add(reportContent.getTemplateFile().getDataProvider().getBytes());
				}

            } else {
                report = JasperUtil.restoreImagesName(report);
                report = JasperUtil.restoreSubreportsInMaster(report);

                JasperContent jrc = (JasperContent) report.getContent();
                List<JcrFile> entries = jrc.getJasperFiles();
                for (JcrFile entry : entries) {
                    files.add(entry.getName());
                    contents.add(entry.getDataProvider().getBytes());
                }

                JcrFile paramEntry = jrc.getParametersFile();
                if (paramEntry != null) {
                    files.add(paramEntry.getName());
                    contents.add(paramEntry.getDataProvider().getBytes());
                }

                if (jrc.getImageFiles() != null) {
                    for (JcrFile entry : jrc.getImageFiles()) {
                        files.add(entry.getName());
                        contents.add(entry.getDataProvider().getBytes());
                    }
                }
            }

            if (reports.size() == 1) {
                try {
                    zip = FileUtil.zip(files, contents);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else {
                filesMap.put(folder, files);
                contentsMap.put(folder, contents);
            }
        }

        if (reports.size() > 1) {
            try {
                zip = FileUtil.zip(filesMap, contentsMap);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return zip;
    }
469646
public static byte[] encodeBZ(byte[] data) {
    try {
      int blockSize = 4;
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      BZip2CompressorOutputStream compresser = new BZip2CompressorOutputStream(output, blockSize);
      compresser.write(data);
      compresser.close();
      byte[] bytes = output.toByteArray();
      return bytes;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
1170932
public boolean buildData(String[] data) {
        final int length = data.length;

        for (int i = 0; i < length; i++) {
            addAddressToList(data[i]);
        }

        return true;
    }
579047
public static String encode(byte[] data) {
	StringBuilder builder = new StringBuilder();
	for (int position = 0; position < data.length; position += 3) {
	    builder.append(encodeGroup(data, position));
	}
	return builder.toString();
    }
148378
public ScriptBuilder data(int index, byte[] data) {
        // implements BIP62
        byte[] copy = Arrays.copyOf(data, data.length);
        int opcode;
        if (data.length == 0) {
            opcode = OP_0;
        } else if (data.length == 1) {
            byte b = data[0];
            if (b >= 1 && b <= 16)
                opcode = Script.encodeToOpN(b);
            else
                opcode = 1;
        } else if (data.length < OP_PUSHDATA1) {
            opcode = data.length;
        } else if (data.length < 256) {
            opcode = OP_PUSHDATA1;
        } else if (data.length < 65536) {
            opcode = OP_PUSHDATA2;
        } else {
            throw new RuntimeException("Unimplemented");
        }
        return addChunk(index, new ScriptChunk(opcode, copy));
    }
678331
public File append(byte[] data, int off, int len) throws IORuntimeException {
		return write(data, off, len, true);
	}
467781
@SuppressWarnings("unchecked")
    public BaseBo fromByteArray(byte[] data) {
        Map<String, Object> dataMap = null;
        try {
            dataMap = data != null ? SerializationUtils.fromByteArray(data, Map.class) : null;
        } catch (Exception e) {
            dataMap = null;
        }
        return fromMap(dataMap);
    }
407987
public static byte[] encode(byte[] data)
	{
		int sourceChunks = data.length / 3;
		int len = (data.length + 2) / 3 * 4;
		byte[] result = new byte[len];
		int extraBytes = data.length - sourceChunks * 3;
		// Each 4 bytes of input (encoded) we end up with 3 bytes of output
		int dataIndex = 0;
		int resultIndex = 0;
		int allBits = 0;
		for (int i = 0; i < sourceChunks; i++)
		{
			allBits = 0;
			// Loop 3 times gathering input bits (3 * 8 = 24)
			for (int j = 0; j < 3; j++)
			{
				allBits = allBits << 8 | data[dataIndex++] & 0xff;
			}
			// Loop 4 times generating output bits (4 * 6 = 24)
			for (int j = resultIndex + 3; j >= resultIndex; j--)
			{
				result[j] = (byte) digits[allBits & 0x3f]; // Bottom
				// 6
				// bits
				allBits = allBits >>> 6;
			}
			resultIndex += 4; // processed 4 result bytes
		}
		// Now we do the extra bytes in case the original (non-encoded) data
		// is not multiple of 4 bytes
		switch (extraBytes)
		{
			case 1:
				allBits = data[dataIndex++]; // actual byte
				allBits = allBits << 8; // 8 bits of zeroes
				allBits = allBits << 8; // 8 bits of zeroes
				// Loop 4 times generating output bits (4 * 6 = 24)
				for (int j = resultIndex + 3; j >= resultIndex; j--)
				{
					result[j] = (byte) digits[allBits & 0x3f]; // Bottom
					// 6
					// bits
					allBits = allBits >>> 6;
				}
				// 2 pad tags
				result[result.length - 1] = equalSign;
				result[result.length - 2] = equalSign;
				break;
			case 2:
				allBits = data[dataIndex++]; // actual byte
				allBits = allBits << 8 | data[dataIndex++] & 0xff; // actual
				// byte
				allBits = allBits << 8; // 8 bits of zeroes
				// Loop 4 times generating output bits (4 * 6 = 24)
				for (int j = resultIndex + 3; j >= resultIndex; j--)
				{
					result[j] = (byte) digits[allBits & 0x3f]; // Bottom
					// 6
					// bits
					allBits = allBits >>> 6;
				}
				// 1 pad tag
				result[result.length - 1] = equalSign;
				break;
		}
		return result;
	}
839716
public static void zipFiles(List<File> files, File zipFile) throws IOException {
        OutputStream os = new BufferedOutputStream(new FileOutputStream(zipFile));
        try {
            zipFiles(files, os);
        } finally {
            IOUtils.closeQuietly(os);
        }
    }
1109762
protected function extractFilesFromDataArray(&$data)
    {
        $files = [];

        foreach ($data as $key => $value) {
            if ($value instanceof SymfonyUploadedFile) {
                $files[$key] = $value;

                unset($data[$key]);
            }

            if (is_array($value)) {
                $files[$key] = $this->extractFilesFromDataArray($value);

                $data[$key] = $value;
            }
        }

        return $files;
    }
547449
public static String encode(byte[] data)
  {
	  StringBuffer result = new StringBuffer();

    for (int i = 0; i < data.length; i++) {
	    result.append(trans[(data[i] >> 4) & 0xf]);
	    result.append(trans[data[i] & 0xf]);
	  }

    return result.toString();
  }
196012
protected function extractFilesFromDataArray(&$data)
    {
        $files = [];

        foreach ($data as $key => $value) {
            if ($value instanceof SymfonyUploadedFile) {
                $files[$key] = $value;

                unset($data[$key]);
            }
        }

        return $files;
    }