packagecn.ucmed.impl;importlombok.extern.slf4j.Slf4j;import java.io.*;import java.util.*;
@Slf4jpublic class SougouScelFileProcessing extendsFileProcessing {protected static String encoding = "UTF-16LE";protected ByteArrayOutputStream output = newByteArrayOutputStream();/*** 解析单个或者多个文件,如果是多个文件则生成对应的txt文件,{@link#setTargetDir(String)},
* 如果targetDir不设置,则在当前文件夹下生成相应的txt文件
*
*@paramfilePath 源文件路径
*@paramisAppend false:覆盖内容 true:附加内容*/@Overridepublic void parseFile(String filePath, booleanisAppend) {
File file= newFile(filePath);if(file.isDirectory()) {
File items[]=file.listFiles();for (int i = 0; i < items.length; i++) {if (!items[i].getName().endsWith(".scel")) {continue;
}if (targetDir == null) {
parseFile(items[i].getAbsolutePath(), items[i].getAbsolutePath().replace(".scel", ".txt"),
isAppend);
}else{
parseFile(items[i].getAbsolutePath(), targetDir+ "/" + items[i].getName().replace(".scel", ".txt"),
isAppend);
}
}
}else{
parseFile(filePath, file.getAbsolutePath().replace(".scel", ".txt"), isAppend);
}
}/*** 解析单个scel文件
*
*@paramfilePath 源文件路径
*@paramtargetFilePath
*@paramisAppend false:覆盖内容 true:附加内容*/@Overridepublic void parseFile(String filePath, String targetFilePath, booleanisAppend) {if (!targetFilePath.endsWith(".txt")) {throw new IllegalStateException("文件格式错误,后缀必须为.txt,此格式为 " +targetFilePath);
}if (!filePath.end