Skip to content

Conversation

XenoAmess
Copy link

No description provided.

@pjfanning
Copy link
Member

This is a big diff - and I'm not sure what we gain from it - what is so wrong with FileOutputStream?

foot.createParagraph().createRun().setText("footer");

try (OutputStream os = new FileOutputStream(new File("header2.docx"))) {
try (OutputStream os = Files.newOutputStream(new File("header2.docx").toPath())) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating File object and then using toPath() to convert to Path, you can directly create Path object with java.nio.file.Paths::get static method.

@cowwoc
Copy link

cowwoc commented Nov 19, 2023

@pjfanning One of benefits of using Path instead of File is that it abstracts away whether you're reading normal (expanded) files, or files inside compressed files like JAR, ZIP, etc. Overall, it is more flexible and Files provides a lot of useful utility methods that you can build on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants