我需要在可移动SD卡上截断文件。由于存储访问框架(SAF)限制,我无法直接在文件上调用 truncate(someSize)并被强制使用:
newx = x(:,1) + x(:,2)(nonzeros)
= [1 2 3 4 5 1 2 3];
结果我有一个例外:
ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(documentFile.getUri(), "rw");
FileOutputStream fos = new FileOutputStream(pfd.getFileDescriptor());
fileChannel = fos.getChannel();
fileChannel.truncate(someSize);
如果我在 rw 模式下打开文件描述符,为什么上面的频道不可写?还有另一种方法在Lollipop上截断SAF下的文件!?