java如何获取wps版本号(Java读取.wps后缀名文档的代码?)
1.Java读取.wps后缀名文档的代码?
可以通过流的方式加载.wps文档,下面以读取文档中的文字保存到本地为例,你参考看看如何读取的。
import com.spire.doc.*;import java.io.File;import java.io.FileInputStream;import java.io.FileWriter;import java.io.IOException;public class ReadTextFromWPS {public static void main(String[] args) throws IOException{//通过流加载WPS文字文档FileInputStream inputStream = new FileInputStream(new File("test.wps"));Document doc = new Document();doc.loadFromStream(inputStream, FileFormat.Doc);//获取文本保存为StringString text = doc.getText();//将String写入TxtwriteStringToTxt(text,"读取WPS文本.txt");}public static void writeStringToTxt(String content, String txtFileName) throws IOException {FileWriter fWriter= new FileWriter(txtFileName,true);try {fWriter.write(content);}catch(IOException ex){ex.printStackTrace();}finally{try{fWriter.flush();fWriter.close();} catch (IOException ex) {ex.printStackTrace();}}}} 读取结果: 注意在程序中导入spire.doc.jar。

2.java实现word文档自动转成pdf文档我现在在做一个网站,客
没自动的。
你可以把软件安装好了点文件-导入\导出 来转换成PDF文件 也可以用WPS, 这是我自己下载了在用的,很好用的版本: Office。
2003。SP2。
龙卷风大企业版 V2。2 2。
2 658M ISO 此ISO整合SP2升级包,免激活,免序列号,支持在线更新 包含下列组件: Microsoft Office Word 2003 Microsoft Office Excel 2003 Microsoft Office PowerPoint 2003 Microsoft Office FrontPage 2003 Microsoft Office Access 2003 Microsoft Office Outlook 2003 Microsoft Office OneNote 2003 Microsoft Office Visio 2003 Microsoft Office InfoPath 2003 Microsoft Office Publisher 2003 Microsoft Office Project 2003 安装说明:先卸载你原来的版本,然后全新安装此版即可 。

3.java获取当前用户的IP地址代码!怎么样调用的?初学者!希望大? 爱
1获取本机的IP地址 Java代码 private static String getIpAddress() throws UnknownHostException { InetAddress address = InetAddress。
getLocalHost(); return address。getHostAddress(); } private static String getIpAddress() throws UnknownHostException { InetAddress address = InetAddress。
getLocalHost(); return address。getHostAddress(); } 2获得网卡地址 Java代码 public static String getMACAddress(){ String address = ""; String os = System。
getProperty("os。name"); String osUser=System。
getProperty("user。name"); if (os != null && os。
startsWith("Windows")) { try { String command = "cmd。 exe /c ipconfig /all"; Process p = Runtime。
getRuntime()。exec(command); BufferedReader br =new BufferedReader(new InputStreamReader(p。
getInputStream())); String line; while ((line = br。readLine()) != null) { if (line。
indexOf("Physical Address") > 0) { int index = line。 indexOf(":"); index = 2; address = line。
substring(index); break; } } br。close(); return address。
trim(); } catch (IOException e) { } } return address; } public static String getMACAddress(){ String address = ""; String os = System。 getProperty("os。
name"); String osUser=System。getProperty("user。
name"); if (os != null && os。startsWith("Windows")) { try { String command = "cmd。
exe /c ipconfig /all"; Process p = Runtime。getRuntime()。
exec(command); BufferedReader br =new BufferedReader(new InputStreamReader(p。 getInputStream())); String line; while ((line = br。
readLine()) != null) { if (line。indexOf("Physical Address") > 0) { int index = line。
indexOf(":"); index = 2; address = line。substring(index); break; } } br。
close(); return address。trim(); } catch (IOException e) { } } return address; } 3获得操作系统帐号 Java代码 String osUser=System。
getProperty("user。name"); String osUser=System。
getProperty("user。name"); 4获得操作系统版本 Java代码 1。
import java。 util。
Properties; 2。 3。
Properties props=System。getProperties(); //获得系统属性集 4。
String osName = props。getProperty("os。
name"); //操作系统名称 5。 String osArch = props。
getProperty("os。arch"); //操作系统构架 6。
String osVersion = props。getProperty("os。
version"); //操作系统版本 1。 import java。
util。Properties; 2。
3。 Properties props=System。
getProperties(); //获得系统属性集 4。 String osName = props。
getProperty("os。name"); //操作系统名称 5。
String osArch = props。getProperty("os。
arch"); //操作系统构架 6。 String osVersion = props。
getProperty("os。version"); //操作系统版本 5一些常用的信息获得 Java代码 public static String getProperty(String key) 键 相关值的描述 java。
version Java 运行时环境版本 java。vendor Java 运行时环境供应商 java。
vendor。url Java 供应商的 URL java。
home Java 安装目录 java。vm。
specification。 version Java 虚拟机规范版本 java。
vm。specification。
vendor Java 虚拟机规范供应商 java。vm。
specification。name Java 虚拟机规范名称 java。
vm。version Java 虚拟机实现版本 java。
vm。vendor Java 虚拟机实现供应商 java。
vm。name Java 虚拟机实现名称 java。
specification。version Java 运行时环境规范版本 java。
specification。vendor Java 运行时环境规范供应商 java。
specification。name Java 运行时环境规范名称 java。
class。version Java 类格式版本号 java。
class。path Java 类路径 java。
library。path 加载库时搜索的路径列表 java。
io。tmpdir 默认的临时文件路径 java。
compiler 要使用的 JIT 编译器的名称 java。ext。
dirs 一个或多个扩展目录的路径 os。name 操作系统的名称 os。
arch 操作系统的架构 os。version 操作系统的版本 file。
separator 文件分隔符(在 UNIX 系统中是“/”) path。separator 路径分隔符(在 UNIX 系统中是“:”) line。
separator 行分隔符(在 UNIX 系统中是“/n”) user。name 用户的账户名称 user。
home 用户的主目录 user。dir 用户的当前工作目录。
4.在EXCEL表格中输入身份证号如何自动提取性别和出生年
公式中的B2是身份证号 根据身份证号码求性别: =IF(LEN(B2)=15,IF(MOD(VALUE(RIGHT(B2,3)),2)=0,"女","男"),IF(LEN(B2)=18,IF(MOD(VALUE(MID(B2,15,1)),2)=0,"女","男"),"身份证错")) 根据身份证号码求年龄:=IF(LEN(B2)=15,2007-VALUE(MID(B2,7,2)),if(LEN(B2)=18,2007-VALUE(MID(B2,7,4)),"身份证错")) 4.Excel表中用Year\Month\Day函数取相应的年月日数据;。
5.Java读取.wps后缀名文档的代码
可以通过流的方式加载.wps文档,下面以读取文档中的文字保存到本地为例,你参考看看如何读取的。
import com.spire.doc.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
public class ReadTextFromWPS {
public static void main(String[] args) throws IOException{
//通过流加载WPS文字文档
FileInputStream inputStream = new FileInputStream(new File("test.wps"));
Document doc = new Document();
doc.loadFromStream(inputStream, FileFormat.Doc);
//获取文本保存为String
String text = doc.getText();
//将String写入Txt
writeStringToTxt(text,"读取WPS文本.txt");
}
public static void writeStringToTxt(String content, String txtFileName) throws IOException {
FileWriter fWriter= new FileWriter(txtFileName,true);
try {
fWriter.write(content);
}catch(IOException ex){
ex.printStackTrace();
}finally{
try{
fWriter.flush();
fWriter.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
读取结果:
注意在程序中导入spire.doc.jar。
