Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Paths #352

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open

use Paths #352

wants to merge 1 commit into from

Conversation

XenoAmess
Copy link

No description provided.

@pjfanning
Copy link
Contributor

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

@@ -48,7 +49,7 @@ public static void main(String[] args) throws IOException {
XWPFFooter foot = doc.createFooter(HeaderFooterType.DEFAULT);
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
4 participants