java解析word文档用什么技术
2个回答
展开全部
java读取word文档时,虽然网上介绍了很多插件poi、java2Word、jacob、itext等等,poi无法读取格式(新的API估
计行好像还在处于研发阶段,不太稳定,做项目不太敢用);java2Word、jacob容易报错找不到注册,比较诡异,我曾经在不同的机器上试过,操作
方法完全一致,有的机器不报错,有的报错,去他们论坛找高人解决也说不出原因,项目部署用它有点玄;itxt好像写很方便但是我查了好久资料没有见到过关
于读的好办法。经过一番选择还是折中点采用rtf最好,毕竟rtf是开源格式,不需要借助任何插件,只需基本IO操作外加编码转换即可。rtf格式文件表
面看来和doc没啥区别,都可以用word打开,各种格式都可以设定。
计行好像还在处于研发阶段,不太稳定,做项目不太敢用);java2Word、jacob容易报错找不到注册,比较诡异,我曾经在不同的机器上试过,操作
方法完全一致,有的机器不报错,有的报错,去他们论坛找高人解决也说不出原因,项目部署用它有点玄;itxt好像写很方便但是我查了好久资料没有见到过关
于读的好办法。经过一番选择还是折中点采用rtf最好,毕竟rtf是开源格式,不需要借助任何插件,只需基本IO操作外加编码转换即可。rtf格式文件表
面看来和doc没啥区别,都可以用word打开,各种格式都可以设定。
展开全部
原因被我找到了,因为你的文件里面有换行,点星不支持,所以改用下面的匹配,你一定能成功的!!!!!
String reg1 = "[\\s\\S]*性别\\s*(:|:)\\s*([^\\|]*)\\|?[\\s\\S]*";
String reg2 = "[\\s\\S]*民族\\s*(:|:)\\s*([^\\|]*)\\|?[\\s\\S]*";
String reg3 = "[\\s\\S]*生日\\s*(:|:)\\s*([\\d\\-]*)\\|?[\\s\\S]*";
String str = "性别:女士|民族:<a href="https://www.baidu.com/s?wd=%E6%B1%89%E6%97%8F&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">汉族</a>|生日:1990-9-22\n" +
"婚姻状况:已婚|身高:165厘米|体重:50公斤\n" +
"<a href="https://www.baidu.com/s?wd=%E6%88%B7%E5%8F%A3%E6%89%80%E5%9C%A8%E5%9C%B0&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">户口所在地</a>:<a href="https://www.baidu.com/s?wd=%E5%B9%BF%E4%B8%9C%E7%9C%81&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">广东省</a><a href="https://www.baidu.com/s?wd=%E9%A1%BA%E5%BE%B7&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">顺德</a>容桂镇|目前所在地:<a href="https://www.baidu.com/s?wd=%E5%B9%BF%E4%B8%9C%E7%9C%81&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">广东省</a><a href="https://www.baidu.com/s?wd=%E9%A1%BA%E5%BE%B7&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">顺德</a>容桂镇";
String sex = str.replaceAll(reg1, "$2");
String mz = str.replaceAll(reg2, "$2");
String brith = str.replaceAll(reg3, "$2");
System.out.println (sex);
System.out.println (mz);
System.out.println (brith);
String reg1 = "[\\s\\S]*性别\\s*(:|:)\\s*([^\\|]*)\\|?[\\s\\S]*";
String reg2 = "[\\s\\S]*民族\\s*(:|:)\\s*([^\\|]*)\\|?[\\s\\S]*";
String reg3 = "[\\s\\S]*生日\\s*(:|:)\\s*([\\d\\-]*)\\|?[\\s\\S]*";
String str = "性别:女士|民族:<a href="https://www.baidu.com/s?wd=%E6%B1%89%E6%97%8F&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">汉族</a>|生日:1990-9-22\n" +
"婚姻状况:已婚|身高:165厘米|体重:50公斤\n" +
"<a href="https://www.baidu.com/s?wd=%E6%88%B7%E5%8F%A3%E6%89%80%E5%9C%A8%E5%9C%B0&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">户口所在地</a>:<a href="https://www.baidu.com/s?wd=%E5%B9%BF%E4%B8%9C%E7%9C%81&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">广东省</a><a href="https://www.baidu.com/s?wd=%E9%A1%BA%E5%BE%B7&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">顺德</a>容桂镇|目前所在地:<a href="https://www.baidu.com/s?wd=%E5%B9%BF%E4%B8%9C%E7%9C%81&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">广东省</a><a href="https://www.baidu.com/s?wd=%E9%A1%BA%E5%BE%B7&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3njNBPynLPHTYrARdmyDY0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3Erj03nH0dnHfYrHcLn10kn1nz" target="_blank" class="baidu-highlight">顺德</a>容桂镇";
String sex = str.replaceAll(reg1, "$2");
String mz = str.replaceAll(reg2, "$2");
String brith = str.replaceAll(reg3, "$2");
System.out.println (sex);
System.out.println (mz);
System.out.println (brith);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |