當前位置:首頁 » 編程語言 » 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 20:37:02 瀏覽:592
域名訪問量查詢 發布:2024-11-27 20:22:13 瀏覽:725
如何清理網頁帳號和登錄密碼 發布:2024-11-27 20:18:53 瀏覽:372
大發明解壓密碼 發布:2024-11-27 20:18:52 瀏覽:502
藍鷗c語言 發布:2024-11-27 20:14:38 瀏覽:813
阿里雲高配伺服器租用 發布:2024-11-27 20:13:40 瀏覽:758
國外圖片上傳 發布:2024-11-27 20:13:31 瀏覽:546
蘋果手機怎麼重置密碼 發布:2024-11-27 20:10:28 瀏覽:533
萬里紅存儲介質信息消除工具 發布:2024-11-27 20:10:13 瀏覽:387
氫怎麼存儲 發布:2024-11-27 20:08:46 瀏覽:837