aboutsummaryrefslogtreecommitdiffstats
path: root/poi-examples/src/main
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-12-30 21:09:08 +0000
committerPJ Fanning <fanningpj@apache.org>2021-12-30 21:09:08 +0000
commit4823d0cbd4add5a5dbb99ce52acb61921362f5b5 (patch)
tree39c60b67ac10b7f9b76897d0aaae7e545b68d093 /poi-examples/src/main
parente35347157de67687924267a7fd012a54ae4e9080 (diff)
downloadpoi-4823d0cbd4add5a5dbb99ce52acb61921362f5b5.tar.gz
poi-4823d0cbd4add5a5dbb99ce52acb61921362f5b5.zip
refactor CopyCompare again
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples/src/main')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java b/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java
index 8a9e0e2f0e..010504140c 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/hpsf/CopyCompare.java
@@ -22,7 +22,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import org.apache.poi.hpsf.DocumentSummaryInformation;
@@ -63,7 +62,7 @@ import org.apache.poi.util.TempFile;
@SuppressWarnings({"java:S106","java:S4823"})
public final class CopyCompare {
- private PrintStream out = System.out;
+ private CopyCompare() {}
/**
* Runs the example program. The application expects one or two arguments:
@@ -82,10 +81,6 @@ public final class CopyCompare {
* supported.
*/
public static void main(final String[] args) throws IOException {
- new CopyCompare().run(args);
- }
-
- public void run(String[] args) throws IOException {
String originalFileName = null;
String copyFileName = null;
@@ -103,7 +98,11 @@ public final class CopyCompare {
System.exit(1);
}
+ boolean result = compare(originalFileName, copyFileName);
+ System.out.println(result ? "Equal" : "Not equal");
+ }
+ public static boolean compare(String originalFileName, String copyFileName) throws IOException {
// Read the origin POIFS using the eventing API.
final POIFSReader r = new POIFSReader();
try (final POIFSFileSystem poiFs = new POIFSFileSystem();
@@ -123,14 +122,10 @@ public final class CopyCompare {
POIFSFileSystem cpfs = new POIFSFileSystem(new File(copyFileName))) {
final DirectoryEntry oRoot = opfs.getRoot();
final DirectoryEntry cRoot = cpfs.getRoot();
- out.println(EntryUtils.areDirectoriesIdentical(oRoot, cRoot) ? "Equal" : "Not equal");
+ return EntryUtils.areDirectoriesIdentical(oRoot, cRoot);
}
}
- public void setOut(PrintStream ps) {
- out = ps;
- }
-
private interface InputStreamSupplier {
InputStream get() throws IOException, WritingNotSupportedException;
}