forked from Gitlink/microservices
Merge pull request '修复解析SKILL.md内容时,部分情况下会出现乱码的问题' (#1151) from otto/microservices:aiResourceMRCS into aiResourceMRCS
This commit is contained in:
commit
f6b7c31022
|
|
@ -22,6 +22,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
|||
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -162,13 +163,13 @@ public class AiResourceParseServiceImpl implements IAiResourceParseService {
|
|||
}
|
||||
|
||||
private String readEntryContent(ZipArchiveInputStream zais) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
int len;
|
||||
while ((len = zais.read(buffer)) > 0) {
|
||||
sb.append(new String(buffer, 0, len, StandardCharsets.UTF_8));
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
return sb.toString();
|
||||
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -285,13 +286,13 @@ public class AiResourceParseServiceImpl implements IAiResourceParseService {
|
|||
|
||||
private String readZipEntryContent(ZipFile zf, ZipArchiveEntry entry) throws IOException {
|
||||
try (InputStream is = zf.getInputStream(entry)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
int len;
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
sb.append(new String(buffer, 0, len, StandardCharsets.UTF_8));
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
return sb.toString();
|
||||
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue