由于项目需求,需要上传在线预览生成的office文件,经过一番痛苦的研究,目前已经成功将DOC、DOCX、PPTX不乱码转换成功,PPT当字体不是宋体时出现乱码,至今无法解决,待日后再研究吧。而EXCEL转换未能解决图片问题。能力有限,先上代码吧

POI jar的maven地址:需注意的时,统一版本jar可能却会出现内部一些方法不存在,不明白什么情况,经测试,选择了3.15

    <properties>
<poi.version>3.15</poi.version>
</properties>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-excelant</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
</exclusion>
</exclusions>
</dependency>

java代码如下:

package com.boco.investment.common;

import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.poi.hslf.usermodel.HSLFAutoShape;
import org.apache.poi.hslf.usermodel.HSLFTable;
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.hslf.usermodel.HSLFTextRun;
import org.apache.poi.hssf.converter.ExcelToHtmlConverter;
import org.apache.poi.hssf.usermodel.HSSFPictureData;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.converter.WordToHtmlConverter;
import org.apache.poi.hwpf.usermodel.Picture;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.SlideShowFactory;
import org.apache.poi.xslf.usermodel.*;
import org.apache.poi.xwpf.converter.core.BasicURIResolver;
import org.apache.poi.xwpf.converter.core.FileImageExtractor;
import org.apache.poi.xwpf.converter.xhtml.XHTMLConverter;
import org.apache.poi.xwpf.converter.xhtml.XHTMLOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.List; /**
* Created by wdj on 2017/11/14.
*
* 通过poi将doc、docx、ppt、pptx转为html
* 保存图片的位置在文件所在目录,以文件名创建文件夹下
*/
public class PoiUtils { private static Logger logger = LoggerFactory.getLogger(PoiUtils.class); private static String rootPath = ConfigUtils.getProperty("upload.rootPath"); private static final String IMAGE_SERVER = ConfigUtils.getProperty("file.server"); /**
* poi office文件转html,支持doc,docx,ppt,pptx
* 根据源文件在同一目录下生成相同名称的html文件
*/
public static boolean officeToHtml(String filePath) {
filePath = rootPath + filePath;
String htmlFilePath = FileUtils.getFileNameWithoutExtension(filePath)+".html";
try {
if(checkFile(filePath,"doc")){
return wordToHtml03(filePath,htmlFilePath);
}else if(checkFile(filePath,"docx")){
return wordToHtml07(filePath,htmlFilePath);
}else if(checkFile(filePath,"ppt")){
return pptToHtml03(filePath,htmlFilePath);
}else if(checkFile(filePath,"pptx")){
return pptToHtml07(filePath,htmlFilePath);
}else {
logger.error("poi OfficeToHtml出错,不支持的文件格式");
return false;
}
} catch (Exception e) {
logger.error("poi OfficeToHtml出错:",e);
return false;
}
} /**
* Word03 转为 HTML
*
* @param fileName
* @param outputFile
*/
public static boolean wordToHtml03(String fileName, String outputFile){
if (!(checkFile(fileName,"doc")||checkFile(fileName,"docx"))) {
logger.error("word03文件转html出错,不支持类型为:"+fileName.substring(fileName.lastIndexOf("."))+" 的文件");
return false;
}
HWPFDocument wordDoc = null;
WordToHtmlConverter wthc = null;
try {
wordDoc = new HWPFDocument(new FileInputStream(fileName));
wthc = new WordToHtmlConverter(
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
} catch (Exception e) {
logger.error("word03转html失败",e);
return false;
}
//html引用图片位置
wthc.setPicturesManager((bytes,pt,string,f,f1) ->getImageUrl(fileName)+string);
wthc.processDocument(wordDoc);
List<Picture> pics = wordDoc.getPicturesTable().getAllPictures();
fileExists(getImageSavePath(fileName));
if (null != pics && pics.size() > 0) {
for (Picture pic : pics) {
try {
//生成图片位置
pic.writeImageContent(new FileOutputStream(getImageSavePath(fileName)+pic.suggestFullFileName()));
} catch (IOException e) {
logger.error("word03转html失败",e);
return false;
}
}
}
Document htmlDocument = wthc.getDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(out); try {
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.METHOD, "html");
serializer.transform(domSource, streamResult);
} catch (TransformerException e) {
logger.error("word03转html失败",e);
return false;
} finally {
try {
out.close();
} catch (IOException e) {
logger.error("word03转html文件流关闭失败",e);
}
}
String htmlStr = new String(out.toByteArray());
return writeFile(htmlStr, outputFile);
} /**
* Word07 转为 HTML
*
* @param fileName
* @param outputFile
*/
public static boolean wordToHtml07(String fileName, String outputFile){
if (!checkFile(fileName,"docx")) {
logger.error("word07文件转html出错,不支持类型为:"+fileName.substring(fileName.lastIndexOf("."))+" 的文件");
return false;
}
//读取文档内容
XWPFDocument document = null;
try {
InputStream in = new FileInputStream(fileName);
document = new XWPFDocument(in);
} catch (IOException e) {
logger.error("word07转html失败",e);
return false;
}
//加载html页面时图片路径
XHTMLOptions options = XHTMLOptions.create().URIResolver( new BasicURIResolver(getImageUrl(fileName)));
//图片保存文件夹路径
fileExists(getImageSavePath(fileName));
options.setExtractor(new FileImageExtractor(new File(getImageSavePath(fileName))));
OutputStream out = null;
try {
out = new FileOutputStream(new File(outputFile));
XHTMLConverter.getInstance().convert(document, out, options);
return true;
} catch (IOException e) {
logger.error("word07转html失败",e);
return false;
} finally {
try {
out.close();
} catch (IOException e) {
logger.error("word07转html文件流关闭失败",e);
}
}
} /**
* excel to html
* @param path
* @param file
*/
// todo 待完成
public static void testExcel(String path,String file) {
HSSFWorkbook excelBook= null;
ExcelToHtmlConverter excelToHtmlConverter = null;
try {
InputStream input=new FileInputStream(path+file);
excelBook = new HSSFWorkbook(input);
excelToHtmlConverter = new ExcelToHtmlConverter(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument() );
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} //加载html页面时图片路径
XHTMLOptions options = XHTMLOptions.create().URIResolver( new BasicURIResolver(getImageUrl(path)));
//图片保存文件夹路径
options.setExtractor(new FileImageExtractor(new File(getImageSavePath(path))));
excelToHtmlConverter.setOutputRowNumbers(false);
excelToHtmlConverter.setOutputHiddenRows(false);
excelToHtmlConverter.setOutputColumnHeaders(false);
excelToHtmlConverter.setOutputHiddenColumns(true);
excelToHtmlConverter.processWorkbook(excelBook);
List pics = excelBook.getAllPictures();
if (pics != null) {
for (int i = 0; i < pics.size(); i++) {
HSSFPictureData pic = (HSSFPictureData) pics.get (i);
try {
// pic.writeImageContent (new FileOutputStream (path + pic.suggestFullFileName() ) );
new FileOutputStream (path + "11" ).write(pic.getData());
} catch (IOException e) {
e.printStackTrace();
} }
}
Document htmlDocument =excelToHtmlConverter.getDocument();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DOMSource domSource = new DOMSource (htmlDocument);
StreamResult streamResult = new StreamResult (outStream);
TransformerFactory tf = TransformerFactory.newInstance();
try {
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty (OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty (OutputKeys.INDENT, "yes");
serializer.setOutputProperty (OutputKeys.METHOD, "html");
serializer.transform (domSource, streamResult);
} catch (TransformerException e) {
e.printStackTrace();
} finally {
try {
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String content = new String (outStream.toByteArray() ); try {
FileUtils.writeStringToFile(new File (path, "exportExcel.html"), content, "utf-8");
} catch (IOException e) {
e.printStackTrace();
}
} /**
* ppt03转html
* filepath:源文件
* htmlname:生成html名称
* */
public static boolean pptToHtml03(String filepath, String outputFile){
File file = new File(filepath);
// 读入PPT文件
if (!checkFile(filepath,"ppt")) {
logger.error("ppt03文件转html出错,不支持类型为:"+FileUtils.getFileExtension(filepath)+" 的文件");
return false;
}
FileInputStream is = null;
SlideShow ppt;
try {
is = new FileInputStream(file);
ppt = SlideShowFactory.create(is);
} catch (IOException e) {
logger.error("ppt03文件转html出错:",e);
return false;
} finally {
try {
is.close();
} catch (IOException e) {
logger.error("ppt03文件转html关闭文件流失败:",e);
}
} Dimension pgsize = ppt.getPageSize();
List<Slide> slide = ppt.getSlides();
FileOutputStream out =null;
String imghtml="";
//保存图片位置
fileExists(getImageSavePath(filepath));
for (int i = 0; i < slide.size(); i++) {
for (Object o : slide.get(i).getShapes()) {
if(o instanceof HSLFAutoShape) {
HSLFAutoShape shapes = (HSLFAutoShape)o;
List<HSLFTextParagraph> list = shapes.getTextParagraphs();
for (HSLFTextParagraph hslfTextRuns : list) {
for (HSLFTextRun hslfTextRun : hslfTextRuns.getTextRuns()) {
hslfTextRun.setFontFamily("宋体");
}
}
}else if(o instanceof HSLFTable){
HSLFTable hslfTable = (HSLFTable) o;
int rowSize = hslfTable.getNumberOfRows();
int columnSize = hslfTable.getNumberOfColumns();
for (int j = 0; j < rowSize; j++) {
for (int k = 0; k < columnSize; k++) {
for (int l =0;l < hslfTable.getCell(j, k).getTextParagraphs().size();l++){
HSLFTextParagraph hslfTextRuns = hslfTable.getCell(j, k).getTextParagraphs().get(l);
for (int m = 0;m < hslfTextRuns.getTextRuns().size();m++){
HSLFTextRun textRun = hslfTextRuns.getTextRuns().get(m);
//todo 设置字体失败,输出html依旧会乱码
textRun.setFontFamily("宋体");
}
}
}
}
}
}
BufferedImage img = new BufferedImage(pgsize.width,pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics();
graphics.setPaint(Color.BLUE);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
slide.get(i).draw(graphics);
// 这里设置图片的存放路径和图片的格式(jpeg,png,bmp等等),注意生成文件路径与源文件同一个目录
try {
out= new FileOutputStream(getImageSavePath(filepath)+(i + 1) + ".jpeg");
javax.imageio.ImageIO.write(img, "jpeg", out);
} catch (IOException e) {
logger.error("ppt03文件转html出错:",e);
try {
out.close();
} catch (IOException e1) {
logger.error("ppt03文件转html关闭文件流失败:",e);
}
return false;
}
//图片在html加载路径
String imgs=getImageUrl(filepath)+(i + 1) + ".jpeg";
imghtml+="<img src=\'"+imgs+"\' style=\'width:1200px;height:830px;vertical-align:text-bottom;\'><br><br><br><br>"; }
DOMSource domSource = new DOMSource();
StreamResult streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance();
try {
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.METHOD, "html");
serializer.transform(domSource, streamResult);
} catch (TransformerException e) {
logger.error("ppt03文件转html出错:",e);
return false;
} finally {
try {
out.close();
} catch (IOException e) {
logger.error("ppt03文件转html关闭文件流失败:",e);
}
} String ppthtml="<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>"+imghtml+"</body></html>";
try {
FileUtils.writeStringToFile(new File(outputFile), ppthtml, "utf-8");
} catch (IOException e) {
logger.error("ppt03文件转html出错:",e);
return false;
}
return true;
} /**
* ppt07转html
* filepath:源文件
* outputFile:生成html名称
* */
public static boolean pptToHtml07(String filepath,String outputFile) {
File file = new File(filepath);
// 读入PPT文件
if (!checkFile(filepath,"pptx")) {
logger.error("ppt07文件转html出错,不支持类型为:"+FileUtils.getFileExtension(filepath)+" 的文件");
return false;
}
FileInputStream is = null;
SlideShow ppt;
try {
is = new FileInputStream(file);
ppt = SlideShowFactory.create(is);
} catch (IOException e) {
logger.error("ppt07文件转html出错:",e);
return false;
} finally {
try {
is.close();
} catch (IOException e) {
logger.error("ppt07文件转html关闭文件流失败:",e);
}
}
Dimension pgsize = ppt.getPageSize();
List<XSLFSlide> pptPageXSLFSLiseList=ppt.getSlides();
FileOutputStream out=null;
String imghtml="";
//保存图片位置
fileExists(getImageSavePath(filepath));
for (int i = 0; i < pptPageXSLFSLiseList.size(); i++) {
for(XSLFShape shape : pptPageXSLFSLiseList.get(i).getShapes()){
//设置文字字体
if(shape instanceof XSLFTextShape) {
XSLFTextShape tsh = (XSLFTextShape)shape;
for(XSLFTextParagraph p : tsh){
for(XSLFTextRun r : p){
r.setFontFamily("宋体");
}
}
//设置表格字体
}else if(shape instanceof XSLFTable){
XSLFTable table = (XSLFTable)shape;
int rowSize = table.getNumberOfRows();
int columnSize = table.getNumberOfColumns();
for (int j = 0; j < rowSize; j++) {
for (int k = 0; k < columnSize; k++) {
for (int l =0;l < table.getCell(j, k).getTextParagraphs().size();l++){
XSLFTextParagraph xslfTextRuns = table.getCell(j, k).getTextParagraphs().get(l);
for (int m = 0;m < xslfTextRuns.getTextRuns().size();m++){
xslfTextRuns.getTextRuns().get(m).setFontFamily("宋体");
}
}
}
}
}
}
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
graphics.setPaint(Color.white);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
pptPageXSLFSLiseList.get(i).draw(graphics);
//设置图片存放位置
String Imgname = getImageSavePath(filepath) + (i+1) + ".jpg";
try {
out = new FileOutputStream(Imgname);
javax.imageio.ImageIO.write(img, "jpg", out);
} catch (java.io.IOException e) {
logger.error("ppt07文件转html出错:",e);
try {
out.close();
} catch (IOException e1) {
logger.error("ppt07文件转html关闭流出错:",e);
}
return false;
}
//图片在html加载路径
String imgs=getImageUrl(filepath)+(i + 1) + ".jpg";
imghtml+="<img src=\'"+imgs+"\' style=\'width:1200px;height:830px;vertical-align:text-bottom;\'><br><br><br><br>";
} DOMSource domSource = new DOMSource();
StreamResult streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance();
try {
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty(OutputKeys.METHOD, "html");
serializer.transform(domSource, streamResult);
} catch (TransformerException e) {
logger.error("ppt07文件转html出错:",e);
return false;
}finally {
try {
out.close();
} catch (java.io.IOException e) {
logger.error("ppt07文件转html关闭流出错:",e);
return false;
}
} String ppthtml="<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>"+imghtml+"</body></html>";
try {
FileUtils.writeStringToFile(new File(outputFile), ppthtml, "utf-8");
return true;
} catch (Exception e) {
logger.error("ppt07文件转html关闭流出错:",e);
return false;
}
} /**
* 输出文件流
* @param content
* @param path
* @return
*/
public static boolean writeFile(String content, String path){
FileOutputStream fos = null;
BufferedWriter bw = null; File file = new File(path); try {
fos = new FileOutputStream(file);
bw = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
bw.write(content);
return true;
} catch (java.io.IOException e) {
logger.error("输出文件出错",e);
return false;
}finally {
try {
if (null != bw) {
bw.close();
}
if (null != fos) {
fos.close();
}
} catch (java.io.IOException e) {
logger.error("输出文件关闭流出错",e);
}
}
} /**
* 判断文件夹是否存在,不存在则新建
* @param path
*/
private static void fileExists(String path) {
File file = new File(path);
if (!file.exists()){
file.mkdirs();
}
} /**
* 检查文件类型
* @param fileName
* @return
*/
public static boolean checkFile(String fileName,String type) {
boolean flag = false;
String suffixname = FileUtils.getFileExtension(fileName);
if (suffixname != null && suffixname.equalsIgnoreCase(type)) {
flag = true;
}
return flag;
} /**
* 根据文件全路径获取文件所在路径
* @param fileFullName
* @return
*/
public static String getFilePath(String fileFullName) {
File file = new File(fileFullName);
String filePath = fileFullName.replace(file.getName(),"");
return filePath;
} private static String getImageUrl(String filePath){
filePath = filePath.replace(rootPath,"");
//图片引用地址需要去掉 rootpath
return IMAGE_SERVER+FileUtils.getFileNameWithoutExtension(filePath)+"/";
} private static String getImageSavePath(String filePath){
return FileUtils.getFileNameWithoutExtension(filePath)+File.separator;
} }

POI操作OFFICE转HTML的更多相关文章

  1. apache poi操作office文档----java在线预览txt、word、ppt、execel,pdf代码

    在页面上显示各种文档中的内容.在servlet中的逻辑 word: BufferedInputStream bis = null;  URL url = null;  HttpURLConnectio ...

  2. poi操作excel2007(读取、生成、编辑)

    因为现在再写excel2003版的比较low,所以我在这就不介绍了,直接介绍2007,我所用的编程软件是IDEA poi操作office总共有6个jar包,在pom.xml文件中配置如下,也可下载后直 ...

  3. 全面了解POI操作Microsoft Office(Word、Excel、PowerPoint)

    POI 与 Microsoft Office 1. POI 简介 POI 是 Apache 下的 Jakata 项目的一个子项目,主要用于提供 java 操作 Microsoft Office 办公套 ...

  4. JAVA的POI操作Excel

    1.1Excel简介 一个excel文件就是一个工作簿workbook,一个工作簿中可以创建多张工作表sheet,而一个工作表中包含多个单元格Cell,这些单元格都是由列(Column)行(Row)组 ...

  5. Java操作word文档使用JACOB和POI操作word,Excel,PPT需要的jar包

    可参考文档: http://wibiline.iteye.com/blog/1725492 下载jar包 http://download.csdn.net/download/javashixiaofe ...

  6. java使用POI操作XWPFDocument中的XWPFRun(文本)对象的属性详解

    java使用POI操作XWPFDocument中的XWPFRun(文本)对象的属性详解 我用的是office word 2016版 XWPFRun是XWPFDocument中的一段文本对象(就是一段文 ...

  7. 使用POI操作Excel

    首先要下载所需jar包, 官网:http://poi.apache.org ,POI支持office的所有版本 下载完后,打开“poi-bin-3.10.1-20140818”获取操作excel需要的 ...

  8. apache POI 操作excel<导入导出>

    1.首先导入maven依赖 <!-- POI核心依赖 --> <dependency> <groupId>org.apache.poi</groupId> ...

  9. 利用POI操作不同版本号word文档中的图片以及创建word文档

    我们都知道要想利用java对office操作最经常使用的技术就应该是POI了,在这里本人就不多说到底POI是什么和怎么用了. 先说本人遇到的问题,不同于利用POI去向word文档以及excel文档去写 ...

随机推荐

  1. [心得]暑假DAY1 | 7-7考试总结

    呼.. 正式开始暑假集训. 今天一上午还在搞7-7的考试改题 然而,该来该去,TLE48过不去了 不知道哪的问题,loj上1w3ms(卡常都没能救得了) 至于T1和T3,简单总结一下算了 排序 感觉很 ...

  2. AIDL 的工作原理

    当创建AIDL文件并Clean Project 代码后,会生成相应的Java文件: 先来一段伪代码:类整体结构 /* * This file is auto-generated. DO NOT MOD ...

  3. Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/Cppcc] due to a StackOverflowError. Possible root causes include a too low setting for -Xs

    解决办法:(1)修改D:\Java\apache-tomcat-7.0.88\conf\catalina.properties (122line) (2)如org.apache.catalina.st ...

  4. Nginx-rtmp之配置项的管理

    1. 概述 Nginx-rtmp 对 rtmp{...} 内的配置项划分了几个级别: 直接隶属于 rtmp{} 块内的配置项称为 main 配置项. 直接隶属于 server{} 块内的配置项称为 s ...

  5. Python定时框架 Apscheduler 详解【转】

    内容来自网络: https://www.cnblogs.com/luxiaojun/p/6567132.html 在平常的工作中几乎有一半的功能模块都需要定时任务来推动,例如项目中有一个定时统计程序, ...

  6. C代码输出日志

    模板代码,在实际开发中可以使用: Android.mk文件增加(放到 include $(CLEAR_VARS)下面) LOCAL_LDLIBS += -llog C代码中增加 #include &l ...

  7. 开源缓存框架之ASimpleCache

    ASimpleCache 是一个为android制定的 轻量级的 开源缓存框架.轻量到只有一个java文件(由十几个类精简而来). 1.它可以缓存什么东西? 普通的字符串.JsonObject.Jso ...

  8. 数据库开源框架之GreenDAO

    主页: https://github.com/greenrobot/greenDAO 配置: 添加以下依赖 * compile 'de.greenrobot:greendao:2.1.0' * com ...

  9. wpf prism IRegionManager 和IRegionViewRegistry

    引入了一个新的问题,IRegionViewRegistry和IRegionManager都具有RegisterViewWithRegion方法,二者有区别么? 答案是——没有.我们已经分析过,在Uni ...

  10. 几行python代码解决相关词联想

    日常生活中经常会遇到相关词联想的问题,也就是说输入一个词汇,把相关的词汇查询出来,听起来这个做法也不是太难,但如何去积累那么多的词汇,再用好的算法将相关内容联系起来,本身还是不简单的.笔者认为最简单的 ...