Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
040807a7
Commit
040807a7
authored
Apr 15, 2024
by
张森
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unreleased Resource: Streams(未出租的资源:流) 问题修复
parent
ae7a15a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
51 deletions
+30
-51
WordHtml.java
...n/java/com/yeejoin/equipmanage/common/utils/WordHtml.java
+9
-27
WordHtml.java
.../java/com/yeejoin/amos/patrol/business/util/WordHtml.java
+21
-24
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/WordHtml.java
View file @
040807a7
package
com
.
yeejoin
.
equipmanage
.
common
.
utils
;
package
com
.
yeejoin
.
equipmanage
.
common
.
utils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.cxf.helpers.FileUtils
;
import
org.apache.cxf.helpers.FileUtils
;
import
org.apache.poi.hwpf.HWPFDocument
;
import
org.apache.poi.hwpf.HWPFDocument
;
import
org.apache.poi.hwpf.converter.PicturesManager
;
import
org.apache.poi.hwpf.converter.PicturesManager
;
...
@@ -12,7 +13,6 @@ import org.apache.poi.xwpf.converter.core.IXWPFConverter;
...
@@ -12,7 +13,6 @@ import org.apache.poi.xwpf.converter.core.IXWPFConverter;
import
org.apache.poi.xwpf.converter.xhtml.XHTMLConverter
;
import
org.apache.poi.xwpf.converter.xhtml.XHTMLConverter
;
import
org.apache.poi.xwpf.converter.xhtml.XHTMLOptions
;
import
org.apache.poi.xwpf.converter.xhtml.XHTMLOptions
;
import
org.apache.poi.xwpf.usermodel.XWPFDocument
;
import
org.apache.poi.xwpf.usermodel.XWPFDocument
;
import
org.apache.tika.io.FilenameUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Document
;
...
@@ -194,18 +194,15 @@ public class WordHtml implements AbstractHtml {
...
@@ -194,18 +194,15 @@ public class WordHtml implements AbstractHtml {
public
static
void
xml2Ttml
(
String
docPath
,
String
xsltPath
,
String
hrmlPath
)
{
public
static
void
xml2Ttml
(
String
docPath
,
String
xsltPath
,
String
hrmlPath
)
{
FileInputStream
fis
=
null
;
try
(
FileInputStream
fis1
=
null
;
//创建XML的文件输入流
try
{
FileInputStream
fis
=
new
FileInputStream
(
org
.
apache
.
commons
.
io
.
FilenameUtils
.
normalize
(
docPath
));
//创建XML的文件输入流
//创建XSL文件的输入流
fis
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
docPath
));
FileInputStream
fis1
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
xsltPath
));
PrintStream
stm
=
new
PrintStream
(
hrmlPath
);
)
{
Source
source
=
new
StreamSource
(
fis
);
Source
source
=
new
StreamSource
(
fis
);
//创建XSL文件的输入流
fis1
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
xsltPath
));
Source
template
=
new
StreamSource
(
fis1
);
Source
template
=
new
StreamSource
(
fis1
);
PrintStream
stm
=
new
PrintStream
(
new
File
(
hrmlPath
));
//讲转换后的结果输出到 stm 中即 F:\123.html
//讲转换后的结果输出到 stm 中即 F:\123.html
Result
result
=
new
StreamResult
(
stm
);
Result
result
=
new
StreamResult
(
stm
);
//根据XSL文件创建准个转换对象
//根据XSL文件创建准个转换对象
...
@@ -214,24 +211,9 @@ public class WordHtml implements AbstractHtml {
...
@@ -214,24 +211,9 @@ public class WordHtml implements AbstractHtml {
Transformer
transformer
=
transformerFactory
.
newTransformer
(
template
);
Transformer
transformer
=
transformerFactory
.
newTransformer
(
template
);
//处理xml进行交换
//处理xml进行交换
transformer
.
transform
(
source
,
result
);
transformer
.
transform
(
source
,
result
);
}
catch
(
FileNotFound
Exception
e
)
{
}
catch
(
TransformerException
|
IO
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
TransformerException
e
)
{
e
.
printStackTrace
();
}
finally
{
//关闭文件流
try
{
if
(
null
!=
fis1
)
{
fis1
.
close
();
}
if
(
null
!=
fis
)
{
fis
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/util/WordHtml.java
View file @
040807a7
...
@@ -191,30 +191,27 @@ public class WordHtml implements AbstractHtml {
...
@@ -191,30 +191,27 @@ public class WordHtml implements AbstractHtml {
}
}
public
static
void
xml2Ttml
(
String
docPath
,
String
xsltPath
,
String
hrmlPath
){
public
static
void
xml2Ttml
(
String
docPath
,
String
xsltPath
,
String
hrmlPath
)
{
FileInputStream
fis
=
null
;
try
(
FileInputStream
fis1
=
null
;
//创建XML的文件输入流
try
{
FileInputStream
fis
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
docPath
));
//创建XML的文件输入流
//创建XSL文件的输入流
fis
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
docPath
));
FileInputStream
fis1
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
xsltPath
));
Source
source
=
new
StreamSource
(
fis
);
PrintStream
stm
=
new
PrintStream
(
hrmlPath
);
)
{
//创建XSL文件的输入流
Source
source
=
new
StreamSource
(
fis
);
fis1
=
new
FileInputStream
(
FilenameUtils
.
normalize
(
xsltPath
));
Source
template
=
new
StreamSource
(
fis1
);
Source
template
=
new
StreamSource
(
fis1
);
//讲转换后的结果输出到 stm 中即 F:\123.html
Result
result
=
new
StreamResult
(
stm
);
PrintStream
stm
=
new
PrintStream
(
hrmlPath
);
//根据XSL文件创建准个转换对象
//讲转换后的结果输出到 stm 中即 F:\123.html
TransformerFactory
transformerFactory
=
TransformerFactory
.
newInstance
();
Result
result
=
new
StreamResult
(
stm
);
transformerFactory
.
setFeature
(
XMLConstants
.
FEATURE_SECURE_PROCESSING
,
true
);
//根据XSL文件创建准个转换对象
Transformer
transformer
=
transformerFactory
.
newTransformer
(
template
);
TransformerFactory
transformerFactory
=
TransformerFactory
.
newInstance
();
//处理xml进行交换
transformerFactory
.
setFeature
(
XMLConstants
.
FEATURE_SECURE_PROCESSING
,
true
);
transformer
.
transform
(
source
,
result
);
Transformer
transformer
=
transformerFactory
.
newTransformer
(
template
);
}
catch
(
TransformerException
|
IOException
e
)
{
//处理xml进行交换
e
.
printStackTrace
();
transformer
.
transform
(
source
,
result
);
}
}
catch
(
TransformerException
|
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment