sonarqube质量修复

This commit is contained in:
gaoqr
2024-10-09 12:04:54 +08:00
parent 2e96dd8173
commit 220d0ff28a
36 changed files with 242 additions and 513 deletions
@@ -166,12 +166,14 @@ public class VoiceServiceImpl implements VoiceService{
public void zipFiles(String fileNames, String zipOutName) throws IOException {
WritableByteChannel writableByteChannel = null;
ByteBuffer buffer = ByteBuffer.allocate(2048);
FileInputStream fileInputStream = null;
FileChannel fileChannel = null;
try (ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(zipOutName))) {
writableByteChannel = Channels.newChannel(zipOutputStream);
File source = new File(fileNames);
zipOutputStream.putNextEntry(new ZipEntry(source.getName()));
fileChannel = new FileInputStream(fileNames).getChannel();
fileInputStream = new FileInputStream(fileNames);
fileChannel = fileInputStream.getChannel();
while (fileChannel.read(buffer) != -1) {
//更新缓存区位置
buffer.flip();
@@ -190,6 +192,7 @@ public class VoiceServiceImpl implements VoiceService{
} finally {
IOUtils.closeQuietly(writableByteChannel);
IOUtils.closeQuietly(fileChannel);
IOUtils.closeQuietly(fileInputStream);
buffer.clear();
}
}