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

14
LINES

< > BotCompany Repo | #1020611 // truncateFile (also creates file)

JavaX fragment (include)

import java.nio.channels.FileChannel;

svoid truncateFile(S path, long size) {
  truncateFile(newFile(path), size);
}

svoid truncateFile(File f, long size) ctex {
  FileChannel outChan = newFileOutputStream(f, true).getChannel();
  try {
    outChan.truncate(size);
  } finally {
    outChan.close();
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1020611
Snippet name: truncateFile (also creates file)
Eternal ID of this version: #1020611/5
Text MD5: ae9d85e4385e53a88f6694c5632a562c
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-03 19:01:24
Source code size: 320 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 305 / 352
Version history: 4 change(s)
Referenced in: [show references]