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

13
LINES

< > BotCompany Repo | #1006742 // loadBinaryFilePart

JavaX fragment (include)

1  
static byte[] loadBinaryFilePart(File file, long start, long end) ctex {
2  
  if (file == null) null;
3  
  RandomAccessFile raf = new RandomAccessFile(file, "r");
4  
  int n = toInt(min(raf.length(), end-start));
5  
  byte[] buffer = new byte[n];
6  
  try {
7  
    raf.seek(start);
8  
    raf.readFully(buffer, 0, n);
9  
    return buffer;
10  
  } finally {
11  
    raf.close();
12  
  }
13  
}

Author comment

Began life as a copy of #1006741

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006742
Snippet name: loadBinaryFilePart
Eternal ID of this version: #1006742/8
Text MD5: c23c75952c8a4256f218fc04518216fc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-14 14:53:18
Source code size: 364 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 588 / 876
Version history: 7 change(s)
Referenced in: [show references]