Commit 20084e57 authored by 周亚武's avatar 周亚武

修改合并mp3文件规则

parent 7f2e48b9
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
<resources> <resources>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<filtering>true</filtering> <!-- <filtering>true</filtering>-->
</resource> </resource>
</resources> </resources>
......
package com.mortals.xhx.tts.utils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
/**
* @author ZYW
* @date 2024-08-26 10:50
*/
public class ResourceExporter {
public static void exportResource(String resourcePath, String outputPath) throws IOException {
// 获取资源作为输入流
try (InputStream inputStream = ResourceExporter.class.getClassLoader().getResourceAsStream(resourcePath)) {
// 判断资源是否存在
if (inputStream == null) {
throw new FileNotFoundException("Resource " + resourcePath + " not found");
}
// 输出路径转换为Path对象
Path outputDir = Paths.get(outputPath);
// 确保输出目录存在
Files.createDirectories(outputDir);
// 输出文件的完整路径
Path outputFile = outputDir.resolve(resourcePath);
// 将资源复制到输出文件
Files.copy(inputStream, outputFile, StandardCopyOption.REPLACE_EXISTING);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment