[問題] 關於用FileChannel 分割檔案
各位大家好
最近剛學到用FileChannel 來分割檔案
主要code 如下
for ( int i = 1; i <= tmpFileCount+1; i++ ) {
FileChannel fout = new
FileOutputStream(tmpFilePath(i)).getChannel();
long notTransferredSize = sourceFileSize - perTmpFileSize;
boolean finalLoop = notTransferredSize < perTmpFileSize;
if ( finalLoop ) {
fin.transferTo(transferredSize, notTransferredSize, fout);
} else {
fin.transferTo(transferredSize, perTmpFileSize, fout);
transferredSize += perTmpFileSize;
}
fout.close();
}
fin.close();
System.out.println("Sperate done");
如果我想要在每個分割後的檔案最後面 加一個換行('\n')
也就是說不要讓原本的最後一行 最後面沒有'\n'
我該怎麼做呢? 是不是FileChannel 不能用 .write ?
謝謝各位大大 <(_ _)>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.23.86.187
→
08/10 16:10, , 1F
08/10 16:10, 1F
→
08/10 16:12, , 2F
08/10 16:12, 2F
→
08/10 16:43, , 3F
08/10 16:43, 3F
→
08/10 17:36, , 4F
08/10 17:36, 4F
→
08/11 09:27, , 5F
08/11 09:27, 5F