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(); } }