JAVA读取PPT文件
import java.io.InputStream;
import org.apache.lucene.document.Document;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.TextRun;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;
public Document getDocument(Index index, String url, String title, InputStream is)
throws DocCenterException {
StringBuffer content = new StringBuffer("");
try{
SlideShow ss = new SlideShow(new HSLFSlideShow(is));//is 为文件的InputStream,建立SlideShow
Slide[] slides = ss.getSlides();//获得每一张幻灯片
for(int i=0;i<slides.length;i++){
TextRun[] t = slides[i].getTextRuns();//为了取得幻灯片的文字内容,建立TextRun
for(int j=0;j<t.length;j++){
content.append(t[j].getText());//这里会将文字内容加到content中去
}
content.append(slides[i].getTitle());
}
index.AddIndex(url, title, content.toString());
}catch(Exception ex){
System.out.println(ex.toString());
}
return null;
}
相关文档:
Java时间设为二十四小时制和十二小时制的区别:
1) 二十四小时制: “yyyy-MM-dd HH:mm:ss”
2)十二小时制: “"yyyy-MM-dd hh:mm:ss"”
例(二十四小时制):
private String getTime(){
Calendar now;
SimpleDateFormat fmt;
now = Calendar.getInstance();
fmt = new S ......
关键语句:
conn.setAutoCommit(false);
if(!ok) conn.rollBack();
// after all done
conn.commit();
conn.setAutoCommit(true);
千万别忘记要加conn.commit()否则不会执行事务的。
另外,M ......
使用Runtime.getRuntime().exec()方法可以在java程序里运行外部程序。
1. exec(String command)
2. exec(String command, String envp[], File dir)
3. exec(String cmd, String envp[])
4. exec(String cmdarray[])
5. exec(String cmdarray[], String envp[])
6. exec(S ......
(2010.02.12) 星星小镇v0.3 定期更新
声明:游戏所有素材来自网络,少部分源码参考Loonframework框架
基本操作:
移动:← → ↓ ↑
对话:空格键
更新日志
2010.02.12 v0.3:
功能添加:标题菜单,场景切换(可以进屋啦)
2010.02.11 v0.2:
功能添加:NPC自由行走会话,背景音乐
2010.02.06 v0 ......