当前位置: 首页 > news >正文

建立个人网站流程王也道长头像

建立个人网站流程,王也道长头像,网站开发需要哪些能力,欧美 电台 网站模板4SpringBoot解压zip包#xff0c;读取每个文件内容 一、运用场景 获取本地压缩包#xff0c;解压后根据文件名称及类型#xff0c;对读取的文件内容进行业务处理。 二、POM文件依赖 !--读取文件--dependencygroupIdorg.apache.poi/groupId读取每个文件内容 一、运用场景 获取本地压缩包解压后根据文件名称及类型对读取的文件内容进行业务处理。 二、POM文件依赖 !--读取文件--dependencygroupIdorg.apache.poi/groupIdartifactIdpoi/artifactIdversion4.1.2/version/dependencydependencygroupIdorg.apache.poi/groupIdartifactIdpoi-ooxml/artifactIdversion4.1.2/version/dependency!--阿里ocr--dependencygroupIdcom.aliyun/groupIdartifactIdaliyun-java-sdk-core/artifactIdversion3.4.0/version/dependencydependencygroupIdsoftware.amazon.awssdk/groupIdartifactIdaws-sdk-java/artifactIdversion2.17.0/version/dependency!--百度ocr--dependencygroupIdcom.baidu.aip/groupIdartifactIdjava-sdk/artifactIdversion4.11.3/versionexclusionsexclusiongroupIdorg.slf4j/groupIdartifactIdslf4j-simple/artifactId/exclusion/exclusions/dependency三、代码部分 1、控制层方法 GetMapping(value /localZipFile)public Result localZipFile(){String filePath C:\\Users\\Administrator\\Desktop\\11.zip;ListString list new ArrayList();try {ZipFile zipFile new ZipFile(filePath);Enumeration? extends ZipEntry entries zipFile.getEntries();//获取zip包下文件名while (entries.hasMoreElements()) {list.add(entries.nextElement().getName());}String packFileStr C:\\Users\\Administrator\\Desktop\\zip;File file new File(filePath);String packFilePath packFileStr File.separator;//解压到指定路径UnPackeUtil.unPackZip(file, null,packFilePath);File readFileDir new File(packFilePath);ListString strings new ArrayList();//获取文件夹下文件集合File[] files readFileDir.listFiles();for (File file1 : files) {String savePath MeFileUtils.uploadLocal(file1,);FileInputStream inputStream new FileInputStream(file1);String fileExtension MeFileUtils. getFileExtension(file1.getName());//返回读取的文件内容String fileContent MeFileUtils.readGsFile(inputStream,fileExtension,file1);strings.add(savePath);strings.add(fileContent);}return Result.OK(strings);} catch (IOException e) {e.printStackTrace();return Result.error(e.getMessage());}2、MeFileUtils工具类 //上传 public class MeFileUtils{public static String uploadLocal(File file,String bizPath){try {String ctxPath uploadpath;String fileName null;File file new File(ctxPath File.separator bizPath File.separator );if (!file.exists()) {file.mkdirs();// 创建文件根目录}// 获取文件名String orgName mf.getName();orgName CommonUtils.getFileName(orgName);if(orgName.indexOf(.)!-1){fileName orgName.substring(0, orgName.lastIndexOf(.)) _ System.currentTimeMillis() orgName.substring(orgName.lastIndexOf(.));}else{fileName orgName _ System.currentTimeMillis();}String savePath file.getPath() File.separator fileName;File savefile new File(savePath);FileCopyUtils.copy(mf, savefile);String dbpath null;if(oConvertUtils.isNotEmpty(bizPath)){dbpath bizPath File.separator fileName;}else{dbpath fileName;}if (dbpath.contains(\\)) {dbpath dbpath.replace(\\, /);}return dbpath;} catch (IOException e) {log.error(e.getMessage(), e);}return ;}//获取文件名public String getFileExtension(String filename) {int dotIndex filename.lastIndexOf(.);if (dotIndex 0 dotIndex filename.length() - 1) {return filename.substring(dotIndex 1).toLowerCase();}return ;}//获取文件内容public String readGsFile(FileInputStream inputStream,String fileExtension,File txtFile) {try {if (fileExtension.equalsIgnoreCase(doc) || fileExtension.equalsIgnoreCase(docx)) {// 处理Word文档XWPFDocument document new XWPFDocument(inputStream);// 读取每个段落的文本内容StringBuilder content new StringBuilder();for (XWPFParagraph paragraph : document.getParagraphs()) {for (XWPFRun run : paragraph.getRuns()) {content.append(run.text());}}// 关闭文档document.close();return content.toString();}else if(fileExtension.equalsIgnoreCase(txt)){StringBuffer buffer new StringBuffer();// 创建Scanner对象来读取文件内容Scanner scanner new Scanner(txtFile);// 逐行读取文件内容并输出while (scanner.hasNextLine()) {String line scanner.nextLine();System.out.println(line);buffer.append(line).append(,);}// 关闭Scanner对象scanner.close();return buffer.toString();} else if (fileExtension.equalsIgnoreCase(xls) || fileExtension.equalsIgnoreCase(xlsx)) {// 处理Excel文档XSSFWorkbook workbook new XSSFWorkbook(inputStream);return ;} else if (fileExtension.equalsIgnoreCase(pdf)) {// 处理PDF文档PDDocument document PDDocument.load(inputStream);// 创建 PDFTextStripper 对象PDFTextStripper textStripper new PDFTextStripper();// 读取文档内容String content textStripper.getText(document);document.close();return content;}else if (fileExtension.equalsIgnoreCase(jpg) || fileExtension.equalsIgnoreCase(png)) {// 处理图片try {// 调用OCR工具类识别文件内容String result BaiduOCRUtil.recognizeFile(txtFile.getAbsolutePath());return result;} catch (Exception e) {e.printStackTrace();return ;}} else {// 其他文件格式inputStream.close();return ;}} catch (IOException e) {e.printStackTrace();return ;}} }3、BaiduOCRUtil工具类 public class BaiduOCRUtil {private static final String APP_ID ;private static final String API_KEY ;private static final String SECRET_KEY ;public static String recognizeFile(String filePath) {AipOcr client new AipOcr(APP_ID, API_KEY, SECRET_KEY);// 设置可选参数HashMapString, String options new HashMap();options.put(language_type, CHN_ENG);options.put(detect_direction, true);options.put(detect_language, true);options.put(probability, true);// 调用百度云OCR服务识别文件内容JSONObject response client.basicGeneral(filePath, options);// 解析识别结果StringBuilder result new StringBuilder();JSONArray wordsArray response.getJSONArray(words_result);for (int i 0; i wordsArray.length(); i) {JSONObject wordsObject wordsArray.getJSONObject(i);String words wordsObject.getString(words);result.append(words).append(\n);}return result.toString();} }一个在学习的开发者勿喷欢迎交流
http://wiki.neutronadmin.com/news/303488/

相关文章:

  • 网站建设考评表环保空调东莞网站建设
  • 网站怎么做站长统计在旅行社做网站运营
  • 祥云平台网站建设网站搭建教学
  • 方案网站有哪些html5网站源代码
  • 建立网站需要准备的材料广州华优_网站建设公司
  • 石家庄行业网站给军方做网站套模板行不行
  • ci策划 网站开发冬夜主题wordpress
  • 网站所有页面只显示域名平湖市住房和城乡规划建设局网站
  • wap企业网站linux网站开发工具
  • wordpress diy插件广州seo网站多少钱
  • 网站建设咨询有客诚信网站建设咨询泰安市住房和城乡建设部网站
  • 丽水开发区建设局网站廉租房苏州十大广告公司
  • seo站内优化公司知乎类 wordpress
  • 商城购物网站建设方案高端网站建设好的公司
  • 网站等比例缩放帮忙建设公司网站
  • 无锡市网站建设关于申请网站建设的请示
  • 网站服务器免费申请wordpress社交图标
  • 安全质量报监建设局网站全屋定制给设计吗
  • flask做的购物网站青海政企网站建设
  • 女人吃男人做床视频网站wix网站做图片能折叠吗
  • 没有网站可以做京东联盟吗电子商务网站建设与设计论文
  • 做pc网站如何实时预览外贸建网站
  • 酷站海洛网站开发软件 论文 摘要
  • 网站建设术语名词如何做漫画网站
  • 西宁高端网站建设备案变更网站信息
  • 网站设计的原则不包括软文优化
  • 网站开发项目计划书模板搜狐快站建设pc网站
  • 南昌企业自助建站wordpress 表单页面
  • 做公司网站需要注意什么域名做好了怎么做网站内容
  • 环保设备在那个网站做深圳市龙岗区住房和建设局