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

12
LINES

< > BotCompany Repo | #1031089 // loadGZTextFile_relaxed - accept incomplete files

JavaX fragment (include)

1  
sS loadGZTextFile_relaxed(File file) ctex {
2  
  if (!file.isFile()) ret null;
3  
  ping();
4  
  new ByteArrayOutputStream baos;
5  
  temp InputStream fis = new FileInputStream(file);
6  
  GZIPInputStream_relaxed gis = new(fis);
7  
  byte[] buffer = new byte[1024];
8  
  int len;
9  
  while ((len = gis.read(buffer)) != -1) baos.write(buffer, 0, len);
10  
  baos.close();
11  
  return fromUtf8(baos.toByteArray()); // TODO: use a Reader
12  
}

Author comment

Began life as a copy of #1005538

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031089
Snippet name: loadGZTextFile_relaxed - accept incomplete files
Eternal ID of this version: #1031089/1
Text MD5: e41ed7b595a628ebbf1202ccfdfcaa7f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-01 00:20:38
Source code size: 417 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 201
Referenced in: [show references]