实际上,只需调用即可获取文件大小
file.length()。尝试更改从文件读取字节的方式:
tarArchiveOutputStream.write(IOUtils.toByteArray(new FileInputStream(path.toFile())));
来自apache commons IO包(http://commons.apache.org/proper/commons-
io/)的IOUtils类。我认为这应该有助于解决您的麻烦。在某些情况下,建议使用@afretas。

实际上,只需调用即可获取文件大小
file.length()。尝试更改从文件读取字节的方式:
tarArchiveOutputStream.write(IOUtils.toByteArray(new FileInputStream(path.toFile())));
来自apache commons IO包(http://commons.apache.org/proper/commons-
io/)的IOUtils类。我认为这应该有助于解决您的麻烦。在某些情况下,建议使用@afretas。