使用FileChannel.truncate:
try (FileChannel outChan = new FileOutputStream(f, true).getChannel()) { outChan.truncate(newSize);}
使用FileChannel.truncate:
try (FileChannel outChan = new FileOutputStream(f, true).getChannel()) { outChan.truncate(newSize);}