当前位置:首页 » 编程语言 » javappt课件

javappt课件

发布时间: 2024-05-10 14:58:17

❶ eclipse-java读取ppt

java中读取ppt的实现方法如下:

public class ReadFileUtils {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ReadFileUtils rf = new ReadFileUtils();
String s = "";
// s = rf.readTXT("E:/itsm文档的后缀名分析报告2.txt");
// s = rf.readPDF("E:/memcached全面剖析.pdf");
// s = rf.readEXCEL("E:/副本工作量及成本模板.xls");
// s = rf.readEXCEL2007("E:/功能点估算方案.xlsx");
// s = rf.readWORD("E:/pms中文.doc");
// s = rf.readWORD2007("E:/功能点估算方法.docx");
//s = rf.readPPT("E:/精细化管理信息系统项目汇报v1.0.ppt");
s = rf.readPPT2007("e:/精细化管理信息系统项目汇报v1.0.pptx");
System.out.println(s);
}

// 读取ppt
public String readPPT(String file) throws IOException {
StringBuilder sb = new StringBuilder();
SlideShow ppt = new SlideShow(new HSLFSlideShow(file));
Slide[] slides = ppt.getSlides();
//提取文本信息
for (Slide each : slides) {
TextRun[] textRuns = each.getTextRuns();
for (int i=0 ;i< textRuns.length; i++ ) {
RichTextRun[] richTextRuns = textRuns.getRichTextRuns();
for (int j = 0; j < richTextRuns.length; j++) {
sb.append(richTextRuns[j].getText());
}
sb.append("\n");
}
sb.append("\n");
}
return sb.toString();
}

// 读取pptx
public String readPPT2007(String file) throws IOException, XmlException, OpenXML4JException {
return new XSLFPowerPointExtractor(POIXMLDocument.openPackage(file)).getText();
}

// 读取xls文件
public String readEXCEL(String file) throws IOException {
StringBuilder content = new StringBuilder();
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));// 创建对Excel工作簿文件的引用
for (int numSheets = 0; numSheets < workbook.getNumberOfSheets(); numSheets++) {
if (null != workbook.getSheetAt(numSheets)) {
HSSFSheet aSheet = workbook.getSheetAt(numSheets);// 获得一个sheet
for (int rowNumOfSheet = 0; rowNumOfSheet <= aSheet
.getLastRowNum(); rowNumOfSheet++) {
if (null != aSheet.getRow(rowNumOfSheet)) {
HSSFRow aRow = aSheet.getRow(rowNumOfSheet); // 获得一个行
for (short cellNumOfRow = 0; cellNumOfRow <= aRow
.getLastCellNum(); cellNumOfRow++) {
if (null != aRow.getCell(cellNumOfRow)) {
HSSFCell aCell = aRow.getCell(cellNumOfRow);// 获得列值
if (this.convertCell(aCell).length() > 0) {
content.append(this.convertCell(aCell));
}
}
content.append("\n");
}
}
}
}
}
return content.toString();
}

// 读取xlsx文件
public String readEXCEL2007(String file) throws IOException {
StringBuilder content = new StringBuilder();
XSSFWorkbook workbook = new XSSFWorkbook(file);
for (int numSheets = 0; numSheets < workbook.getNumberOfSheets(); numSheets++) {
if (null != workbook.getSheetAt(numSheets)) {
XSSFSheet aSheet = workbook.getSheetAt(numSheets);// 获得一个sheet
for (int rowNumOfSheet = 0; rowNumOfSheet <= aSheet
.getLastRowNum(); rowNumOfSheet++) {
if (null != aSheet.getRow(rowNumOfSheet)) {
XSSFRow aRow = aSheet.getRow(rowNumOfSheet); // 获得一个行
for (short cellNumOfRow = 0; cellNumOfRow <= aRow
.getLastCellNum(); cellNumOfRow++) {
if (null != aRow.getCell(cellNumOfRow)) {
XSSFCell aCell = aRow.getCell(cellNumOfRow);// 获得列值
if (this.convertCell(aCell).length() > 0) {
content.append(this.convertCell(aCell));
}
}
content.append("\n");
}
}
}
}
}
return content.toString();
}

private String convertCell(Cell cell) {
NumberFormat formater = NumberFormat.getInstance();
formater.setGroupingUsed(false);
String cellValue = "";
if (cell == null) {
return cellValue;
}

switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
cellValue = formater.format(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_STRING:
cellValue = cell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_BLANK:
cellValue = cell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
cellValue = Boolean.valueOf(cell.getBooleanCellValue()).toString();
break;
case HSSFCell.CELL_TYPE_ERROR:
cellValue = String.valueOf(cell.getErrorCellValue());
break;
default:
cellValue = "";
}
return cellValue.trim();
}

// 读取pdf文件
public String readPDF(String file) throws IOException {
String result = null;
FileInputStream is = null;
PDDocument document = null;
try {
is = new FileInputStream(file);
PDFParser parser = new PDFParser(is);
parser.parse();
document = parser.getPDDocument();
PDFTextStripper stripper = new PDFTextStripper();
result = stripper.getText(document);
} finally {
if (is != null) {
is.close();
}
if (document != null) {
document.close();
}
}
return result;
}

// 读取doc文件
public String readWORD(String file) throws Exception {
String returnStr = "";
try {
WordExtractor wordExtractor = new WordExtractor(new FileInputStream(new File(file)));
returnStr = wordExtractor.getText();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return returnStr;
}

// 读取docx文件
public String readWORD2007(String file) throws Exception {
return new XWPFWordExtractor(POIXMLDocument.openPackage(file)).getText();
}

// 读取txt文件
public String readTXT(String file) throws IOException {
String encoding = ReadFileUtils.get_charset(new File(file));
if (encoding.equalsIgnoreCase("GBK")) {
return FileUtils.readFileToString(new File(file), "gbk");
} else {
return FileUtils.readFileToString(new File(file), "utf8");
}
}

private static String get_charset(File file) throws IOException {
String charset = "GBK";
byte[] first3Bytes = new byte[3];
BufferedInputStream bis = null;
try {
boolean checked = false;
bis = new BufferedInputStream(new FileInputStream(file));
bis.mark(0);
int read = bis.read(first3Bytes, 0, 3);
if (read == -1)
return charset;
if (first3Bytes[0] == (byte) 0xFF && first3Bytes[1] == (byte) 0xFE) {
charset = "UTF-16LE";
checked = true;
} else if (first3Bytes[0] == (byte) 0xFE
&& first3Bytes[1] == (byte) 0xFF) {
charset = "UTF-16BE";
checked = true;
} else if (first3Bytes[0] == (byte) 0xEF
&& first3Bytes[1] == (byte) 0xBB
&& first3Bytes[2] == (byte) 0xBF) {
charset = "UTF-8";
checked = true;
}
bis.reset();
if (!checked) {
// int len = 0;
int loc = 0;

while ((read = bis.read()) != -1) {
loc++;
if (read >= 0xF0)
break;
if (0x80 <= read && read <= 0xBF) // 单独出现BF以下的,也算是GBK
break;
if (0xC0 <= read && read <= 0xDF) {
read = bis.read();
if (0x80 <= read && read <= 0xBF) // 双字节 (0xC0 - 0xDF)
// (0x80
// - 0xBF),也可能在GB编码内
continue;
else
break;
} else if (0xE0 <= read && read <= 0xEF) {// 也有可能出错,但是几率较小
read = bis.read();
if (0x80 <= read && read <= 0xBF) {
read = bis.read();
if (0x80 <= read && read <= 0xBF) {
charset = "UTF-8";
break;
} else
break;
} else
break;
}
}
// System.out.println( loc + " " + Integer.toHexString( read )
// );
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null) {
bis.close();
}
}
return charset;
}
}

❷ java导出ppt太慢

1、你的ppt是否起用了宏或者插入了大量的图片文件等? 没有
2、是否是所有的ppt文件都这样,还是个别的?如果全这样你的硬盘是否可能不正常。 就那个文件
3、内存和虚拟内存是否足够? 足够
重新启动计算机还是很慢

❸ java缂栫▼瑙嗛

銆婅嗛-Java绋嫔簭璁捐°嬬栌搴︾绣鐩樿祫婧愬厤璐逛笅杞介摼鎺:https://pan..com/s/15c5QsBsFV9z-TsWntNZ3Tw

鎻愬彇镰:swjn


瑙嗛-Java绋嫔簭璁捐|瑙嗛戙奂2SE锘虹缂栫▼銆嬨愬緪褰ゃ愦瑙嗛戙婄紪绋嬫柟娉曞︺嬨愭柉鍧︾忓ぇ瀛-CS106A銆慗ava28璁瞸鏁欑▼-Java缂栫▼镐濇兂PDF|鏁欑▼-Java缂栫▼妗堜緥PDF|婧愮爜-Java绋嫔簭璁捐|鏁欑▼-Java寮鍙戞妧链疨DF|璇句欢-Java绋嫔簭璁捐PPT|鏁欑▼-Java鍏ラ棬瀛︿範PDF|瑙嗛戙奂ava瑙嗛戞暀绋嬨媩璧勬枡-Java绋嫔簭璁捐|链鏂癹ava ee api甯锷╂枃妗 chm镙煎纺.chm|璧勬枡-Java绋嫔簭璁捐.rar|瀹为獙鎸囧间功 闱㈠悜瀵硅薄绋嫔簭璁捐(Java)09淇$.doc|瀹为獙鎸囧间功 Java闱㈠悜瀵硅薄绋嫔簭璁捐″强搴旂敤1_12.doc

❹ 鐢↗AVA鍦ㄧ晫闱涓瀹炵幇骞荤伅鐗囨挱鏀撅纴姹备唬镰

瑕佽╃収鐗囬殢链烘挱鏀,闇瑕佹妸镦х墖钖嶆敼鎴愭瘆濡俻hoto1.jpg,photo2.jpg,photo3.jpg...镄勬湁搴忓彿椤哄簭鎺掑垪镄勬枃浠跺悕,
铹跺悗鎶婃敼钖嶅悗镄勭収鐗囨枃浠舵斁鍒颁綘镄勯”鐩钖岖殑鐩褰曚笅,姣斿备綘镄勯”鐩钖嶅彨"slideshow",浣犲氨鎶婄収鐗囨枃浠舵斁鍒皊lideshow鏂囦欢澶逛笅.
链钖庢妸涓嬮溃镄凧ava绋嫔簭𨰾疯礉鍒颁綘镄勯”鐩涓,鎶婃湁DD绫诲悕镄勫湴鏂规敼鎴愪綘镄勭被钖,灏辫屼简.
瀹屾暣镄勮╀竴浜涚収鐗囧湪JFrame绐椾綋閲岃嚜锷ㄩ殢链烘挱鏀剧殑骞荤伅鐗囩▼搴忓备笅
(鎴戠敤镄勫浘鐗囨枃浠舵槸photo1.jpg,photo2.jpg,photo3.jpg,娉ㄦ剰浜嬮”鍦ㄦ敞閲娄腑娉ㄦ槑

import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class DD extends JFrame implements Runnable{
ImageIcon ii=new ImageIcon("photo1.jpg");//杩欓噷鎹㈡垚浣犵殑锲剧墖鏂囦欢钖,鏀惧湪浣犵殑椤圭洰钖岖殑鏂囦欢澶逛腑
DD(){
super("Slide");
setSize(400, 400);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
g.drawImage(ii.getImage(),0,0,400,400,null);
}
@Override
public void run() {
while(true){
try {
Thread.sleep(500);//杩欓噷鏄骞荤伅鐗囨挱鏀鹃棿闅旂殑镞堕棿,杩欓噷涓500姣绉=0.5绉
} catch (InterruptedException e) {
e.printStackTrace();
}
int i=(int)(Math.random()*3)+1;//杩欓噷鏄浜х敓浠1-3镄勯殢链烘暟,濡傛灉浣犳湁6涓锲剧墖鏂囦欢,鎶3鏀规垚6灏辨槸浠1-6镄勯殢链烘暟浜.
ii=new ImageIcon("photo"+i+".jpg");//杩欓噷璋幂敤浣犵殑锲剧墖鏂囦欢,濡傛灉浣犳湁6涓锲剧墖鏂囦欢,鏀规垚浠1-6镄勬枃浠跺悕鏂逛究璋幂敤
this.repaint();
}
}
public static void main(String[] args) {
DD d=new DD();
Thread t=new Thread(d);
t.start();
}
}

热点内容
刀剑乱舞挂机脚本 发布:2024-11-27 18:37:56 浏览:504
截取字符串java 发布:2024-11-27 18:34:09 浏览:331
安卓导航怎么会黑屏 发布:2024-11-27 18:17:19 浏览:394
编译后代码放在单片机哪个位置 发布:2024-11-27 18:12:01 浏览:458
linux红帽安装 发布:2024-11-27 18:01:53 浏览:827
手机编程蓝牙 发布:2024-11-27 17:55:39 浏览:385
创维云电视怎么升级安卓系统 发布:2024-11-27 17:55:31 浏览:354
theisle游戏服务器搭建 发布:2024-11-27 17:47:43 浏览:210
xshell解压 发布:2024-11-27 17:35:14 浏览:359
ftp服务器管理方法 发布:2024-11-27 17:24:48 浏览:975