Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1020478 // bzipString - bzip2-compress an UTF8-encoded string

JavaX fragment (include)

lib 1005255 // apache commons compress

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;

static byte[] bzipString(S s) ctex {
  new ByteArrayOutputStream baos;
  BZip2CompressorOutputStream bzos = new(baos);
  OutputStreamWriter outputStreamWriter = new OutputStreamWriter(bzos, "UTF-8");
  PrintWriter printWriter = new(outputStreamWriter);
  printWriter.print(s);
  printWriter.close();
  bzos.close();
  ret baos.toByteArray();
}

Author comment

Began life as a copy of #1006276

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020478
Snippet name: bzipString - bzip2-compress an UTF8-encoded string
Eternal ID of this version: #1020478/2
Text MD5: 9523b721485c72f75fa40e7912971e63
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-23 19:41:28
Source code size: 479 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 294 / 327
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)