小编Wir*_*der的帖子

Apache POI - 将 Word 文档 (docx) 拆分为页面

我一直在尝试根据预定义的标准将 docx 文档分割为多个文档。以下是我将其切成段落的方法

        try {
        FileInputStream in = new FileInputStream(file);
        XWPFDocument doc = new XWPFDocument(in);
        List<XWPFParagraph> paragraphs = doc.getParagraphs();
        for (int idx = 0; idx < paragraphs.size(); idx++) {
            XWPFDocument outputDocument = new XWPFDocument();
            createParagraphInAnotherDocument(outputDocument, paragraphs.get(idx).getText());
            String fullPath = String.format("./content/output/%1$s_%2$s_%3$04d.docx", FileUtils.getFileName(file), getName(), idx);
            FileOutputStream outputStream = new FileOutputStream(fullPath);
            outputDocument.write(outputStream);
            outputDocument.close();

            doc.close();
        }

    } catch (IOException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

虽然我可以使用上面的代码提取段落,但我找不到提取页面的方法。我的理解是 word 中的页面是渲染关注的,它发生在 word 应用程序的运行时中。

java docx apache-poi xwpf

3
推荐指数
1
解决办法
4586
查看次数

覆盖类加载器"Parent First"

我在Web应用程序服务器单节点设置上运行Java Web应用程序,其中我使用的是我在Web-Inf中包含的自由文件并在我的代码中使用.

问题是我有另一个应用程序将其库添加到WebSphere父lib文件夹,其中一个是我正在使用的相同的版本,但是使用旧版本,会产生冲突并干扰我的代码.

服务器类加载器配置为父首先不可取,我无法改变这一事实.我的问题是,如何让我的应用程序使用我的自由文件,忽略类加载器使用的那个?

java websphere classloader java-ee

2
推荐指数
1
解决办法
401
查看次数

Java记录全局记录器

我有一个桌面java应用程序,我预见到Java日志记录就足够了.为了简化这个问题,我使用java全局记录器获取记录器,而不是传递任何特定的记录器名称

        Logger logger = Logger.getGlobal();
        String logFilePath = Config.INSTANCE.getProperty("logFilePath");
        FileHandler fileHandler = new FileHandler(logFilePath);
        logger.addHandler(fileHandler);
        SimpleFormatter formatter = new SimpleFormatter();
        fileHandler.setFormatter(formatter);
Run Code Online (Sandbox Code Playgroud)

如您所见,我还在输出文件路径和格式化程序方面对全局记录器进行了更改.

我的问题是关于全局记录器的范围,它的全局范围是JVM吗?或全局范围的应用程序?如果全局范围在JVM上,我是否应该对共享相同JVM的应用程序产生副作用?提示:我已经完成了这个线程在java.util.logging中,什么是全局记录器?但评论不是我可以利用的.

java logging

1
推荐指数
1
解决办法
2032
查看次数

标签 统计

java ×3

apache-poi ×1

classloader ×1

docx ×1

java-ee ×1

logging ×1

websphere ×1

xwpf ×1