当前位置: 首页>>代码示例>>Java>>正文


Java Base64OutputStream类代码示例

本文整理汇总了Java中org.apache.commons.codec.binary.Base64OutputStream的典型用法代码示例。如果您正苦于以下问题:Java Base64OutputStream类的具体用法?Java Base64OutputStream怎么用?Java Base64OutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Base64OutputStream类属于org.apache.commons.codec.binary包,在下文中一共展示了Base64OutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
@Override
public CxZipResult invoke(final File file, final VirtualChannel channel) throws IOException, InterruptedException {

    final File tempFile = File.createTempFile("base64ZippedSource", ".bin");
    FilePath remoteTempFile = new FilePath(tempFile);
    final OutputStream fileOutputStream = new FileOutputStream(tempFile);
    final Base64OutputStream base64FileOutputStream = new Base64OutputStream(fileOutputStream, true, 0, null);

    ZippingDetails zippingDetails;
    try {
        zippingDetails = new Zipper().zip(file, combinedFilterPattern, base64FileOutputStream, CxConfig.maxZipSize());
    } catch (Exception e) {
        deleteTempFile(remoteTempFile);
        throw e;

    } finally {
        fileOutputStream.close();
    }

    return new CxZipResult(remoteTempFile, zippingDetails);
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:22,代码来源:SastZipperCallable.java

示例2: doPost

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
    CertificationRequest csr = decoder.decode(new Base64InputStream(request.getInputStream()));

    try {
        response.setContentType(APPLICATION_PKCS7_MIME);
        response.addHeader("Content-Transfer-Encoding", "base64");
        X509Certificate certificate = est.enroll(csr);
        Base64OutputStream bOut = new Base64OutputStream(response.getOutputStream());
        encoder.encode(bOut, certificate);
        bOut.flush();
        bOut.close();

    } catch (IOException e) {
        response.sendError(500);
        response.getWriter().write(e.getMessage());
        response.getWriter().close();

    }

    // 202
    // Retry-After

    // 400
}
 
开发者ID:jscep,项目名称:jester,代码行数:25,代码来源:EnrollmentServlet.java

示例3: encodeFileToBase64Stream

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
public void encodeFileToBase64Stream(Path file, OutputStream base64OutputStream) throws IOException {
	InputStream inputStream = Files.newInputStream(file);
	OutputStream out = new Base64OutputStream(base64OutputStream, true);
	IOUtils.copy(inputStream, out);
	inputStream.close();
	out.close();
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:8,代码来源:GlbSerializer.java

示例4: setOutputStream

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
@Override
public void setOutputStream(OutputStream outputStream) throws XMLSecurityException {
    super.setOutputStream(new Base64OutputStream(
            new FilterOutputStream(outputStream) {
                @Override
                public void close() throws IOException {
                    //do not close the parent output stream!
                    super.flush();
                }
            },
            false)
    );
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:14,代码来源:TransformBase64Decode.java

示例5: marshalStreaming

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
private void marshalStreaming(Exchange exchange, Object graph, OutputStream stream) throws Exception {
    InputStream decoded = ExchangeHelper.convertToMandatoryType(exchange, InputStream.class, graph);

    Base64OutputStream base64Output = new Base64OutputStream(stream, true, lineLength, lineSeparator);
    try {
        IOHelper.copy(decoded, base64Output);
    } finally {
        IOHelper.close(decoded, base64Output);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:Base64DataFormat.java

示例6: compressStream

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
static void compressStream(InputStream inputStream, OutputStream outputStream) throws IOException {
  InputStream iStream = new BufferedInputStream(inputStream);
  GZIPOutputStream oStream =
      new GZIPOutputStream(new Base64OutputStream(new BufferedOutputStream(outputStream), true, -1, null), 2048);
  byte[] buffer = new byte[2048];
  int bytesRead;
  while ((bytesRead = iStream.read(buffer)) != -1) {
    oStream.write(buffer, 0, bytesRead);
  }
  oStream.close(); // this is necessary for the gzip and base64 streams
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:Compressor.java

示例7: getBase64ImageString

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
/**
 * Converts the given image into a base64 encoded string.
 * @param image the image
 * @return String
 * @throws IOException if an exception occurs during write
 */
public static final String getBase64ImageString(RenderedImage image) throws IOException {
	ByteArrayOutputStream bo = new ByteArrayOutputStream();
	Base64OutputStream b64o = new Base64OutputStream(bo);
	ImageIO.write(image, "png", b64o);
	return new String(bo.toByteArray());
}
 
开发者ID:wnbittle,项目名称:praisenter,代码行数:13,代码来源:ImageUtilities.java

示例8: convertString

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
@Override
public void convertString(UTF8StringPointable stringp, DataOutput dOut) throws SystemException, IOException {
    baaos.reset();
    Base64OutputStream b64os = new Base64OutputStream(baaos, false);
    b64os.write(stringp.getByteArray(), stringp.getCharStartOffset(), stringp.getUTF8Length());

    dOut.write(ValueTag.XS_BASE64_BINARY_TAG);
    dOut.write((byte) ((baaos.size() >>> 8) & 0xFF));
    dOut.write((byte) ((baaos.size() >>> 0) & 0xFF));
    dOut.write(baaos.getByteArray(), 0, baaos.size());

    b64os.close();
}
 
开发者ID:apache,项目名称:vxquery,代码行数:14,代码来源:CastToBase64BinaryOperation.java

示例9: convertBase64Binary

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
@Override
public void convertBase64Binary(XSBinaryPointable binaryp, DataOutput dOut) throws SystemException, IOException {
    // Read binary
    Base64OutputStream b64os = new Base64OutputStream(baaos, true);
    b64os.write(binaryp.getByteArray(), binaryp.getStartOffset() + 2, binaryp.getLength() - 2);

    // Write string
    startString();
    sb.appendUtf8Bytes(baaos.getByteArray(), 0, baaos.size());
    sendStringDataOutput(dOut);
}
 
开发者ID:apache,项目名称:vxquery,代码行数:12,代码来源:CastToStringOperation.java

示例10: imageToString

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
public String imageToString(String path) throws Exception {
	BufferedImage img = ImageIO.read(new File(path));
	ByteArrayOutputStream os = new ByteArrayOutputStream();
	OutputStream b64 = new Base64OutputStream(os);
	ImageIO.write(img, "png", b64);
	String result = os.toString("UTF-8");
	HttpURLConnection conn;
	URL url = new URL("https://api.imgur.com/3/image");
	conn = (HttpURLConnection) url.openConnection();
	conn.setDoOutput(true);
	conn.setDoInput(true);
	conn.setRequestMethod("POST");
	conn.setRequestProperty("Authorization", "Client-ID "
			+ "4d9fc949d3d87e9");
	conn.setRequestMethod("POST");
	conn.setRequestProperty("Content-Type",
			"application/x-www-form-urlencoded");

	conn.connect();
	StringBuilder stb = new StringBuilder();
	OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
	wr.write(result);
	wr.flush();

	BufferedReader rd = new BufferedReader(new InputStreamReader(
			conn.getInputStream()));
	String line;
	while ((line = rd.readLine()) != null) {
		stb.append(line).append("\n");
	}
	wr.close();
	rd.close();

	return stb.toString();
}
 
开发者ID:ohdanbo,项目名称:ScreenSlice-Old,代码行数:36,代码来源:imgurUpload.java

示例11: write1KRecordsBase64Only

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
@Benchmark
public byte[] write1KRecordsBase64Only(EncodingBenchmarkState state) throws IOException {
  ByteArrayOutputStream sink = new ByteArrayOutputStream();
  OutputStream os = new Base64OutputStream(sink);
  os.write(state.OneKBytes);
  os.close();

  return sink.toByteArray();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:10,代码来源:EncodingBenchmark.java

示例12: enroll

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
private EnrollmentResponse enroll(CertificationRequest csr, String command) throws IOException {
    HttpPost post = new HttpPost(buildUrl(command));
    post.addHeader("Content-Type", "application/pkcs10");
    post.addHeader("Content-Transfer-Encoding", "base64");
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    Base64OutputStream base64Out = new Base64OutputStream(bOut);
    csrEncoder.encode(base64Out, csr);
    base64Out.flush();
    base64Out.close();
    post.setEntity(new ByteArrayEntity(bOut.toByteArray()));
    HttpResponse response = httpClient.execute(post);

    int statusCode = response.getStatusLine().getStatusCode();
    checkStatusCode(statusCode, 200, 202);
    if (statusCode == 200) {
        checkContentType(response);
        checkContentTransferEncoding(response);

        HttpEntity entity = response.getEntity();
        X509Certificate[] certs = certDecoder.decode(new Base64InputStream(entity.getContent()));

        return new EnrollmentResponse(certs[0]);
    } else {
        String retryAfter = response.getFirstHeader("Retry-After").getValue();
        return new EnrollmentResponse(RetryAfterParser.parse(retryAfter));
    }
}
 
开发者ID:jscep,项目名称:jester,代码行数:28,代码来源:EstClient.java

示例13: doGet

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType(APPLICATION_PKCS7_MIME);
    response.addHeader("Content-Transfer-Encoding", "base64");

    Base64OutputStream bOut = new Base64OutputStream(response.getOutputStream());
    encoder.encode(bOut, est.getCaCertificates());
    bOut.flush();
    bOut.close();
}
 
开发者ID:jscep,项目名称:jester,代码行数:10,代码来源:CaDistributionServlet.java

示例14: encodeBase64ZippedString

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
public static String encodeBase64ZippedString( String in ) throws IOException {
  Charset charset = Charset.forName( Const.XML_ENCODING );
  ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 );
  try ( Base64OutputStream base64OutputStream = new Base64OutputStream( baos );
        GZIPOutputStream gzos = new GZIPOutputStream( base64OutputStream ) ) {
    gzos.write( in.getBytes( charset ) );
  }
  return baos.toString();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:10,代码来源:HttpUtil.java

示例15: encodeBase64Zipped

import org.apache.commons.codec.binary.Base64OutputStream; //导入依赖的package包/类
/**
 * Base64 encodes then zips a byte array into a compressed string
 *
 * @param src the source byte array
 * @return a compressed, base64 encoded string
 * @throws IOException
 */
public static String encodeBase64Zipped( byte[] src ) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 );
  try ( Base64OutputStream base64OutputStream = new Base64OutputStream( baos );
        GZIPOutputStream gzos = new GZIPOutputStream( base64OutputStream ) ) {
    gzos.write( src );
  }
  return baos.toString();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:16,代码来源:EncodeUtil.java


注:本文中的org.apache.commons.codec.binary.Base64OutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。