]> source.dussan.org Git - poi.git/commitdiff
[github-353] Use printf. Thanks to XenoAmess. This closes #353
authorPJ Fanning <fanningpj@apache.org>
Sun, 17 Jul 2022 09:07:07 +0000 (09:07 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sun, 17 Jul 2022 09:07:07 +0000 (09:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902802 13f79535-47bb-0310-9956-ffa450edef68

poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SlideShowDumper.java

index 6f55f394d415ad74b4fd3ec049d1eca0c3afa9ee..084b15b9c1ddd93933f1d2c7887f9bd8e68ef7aa 100644 (file)
 
 package org.apache.poi.hslf.dev;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.Locale;
-
 import org.apache.poi.ddf.DefaultEscherRecordFactory;
 import org.apache.poi.ddf.EscherContainerRecord;
 import org.apache.poi.ddf.EscherRecord;
@@ -35,6 +29,12 @@ import org.apache.poi.util.HexDump;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LittleEndian;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Locale;
+
 /**
  * This class provides a way to "peek" inside a powerpoint file. It
  * will print out all the types it finds, and for those it knows aren't
@@ -185,14 +185,14 @@ public final class SlideShowDumper {
             byte opt = docstream[pos];
 
             String fmt = ind + "At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
-            out.println(String.format(Locale.ROOT, fmt, "", pos, type, len));
+            out.printf(Locale.ROOT, (fmt) + "%n", "", pos, type, len);
 
             // See if we know about the type of it
             String recordName = RecordTypes.forTypeID((short) type).name();
 
             // Jump over header, and think about going on more
             pos += 8;
-            out.println(String.format(Locale.ROOT, ind + "That's a %2$s", "", recordName));
+            out.printf(Locale.ROOT, ind + "That's a %2$s%n", "", recordName);
 
             // Now check if it's a container or not
             int container = opt & 0x0f;
@@ -247,17 +247,17 @@ public final class SlideShowDumper {
         int recordLen = record.getRecordSize();
 
         String fmt = ind + "At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x) (%5$d) - record claims %6$d";
-        out.println(String.format(Locale.ROOT, fmt, "", pos, atomType, atomLen, atomLen + 8, recordLen));
+        out.printf(Locale.ROOT, (fmt) + "%n", "", pos, atomType, atomLen, atomLen + 8, recordLen);
 
 
         // Check for corrupt / lying ones
         if (recordLen != 8 && (recordLen != (atomLen + 8))) {
-            out.println(String.format(Locale.ROOT, ind + "** Atom length of $2d ($3d) doesn't match record length of %4d", "", atomLen, atomLen + 8, recordLen));
+            out.printf(Locale.ROOT, ind + "** Atom length of $2d ($3d) doesn't match record length of %4d%n", "", atomLen, atomLen + 8, recordLen);
         }
 
         // Print the record's details
         String recordStr = record.toString().replace("\n", String.format(Locale.ROOT, "\n" + ind, ""));
-        out.println(String.format(Locale.ROOT, ind + "%2$s", "", recordStr));
+        out.printf(Locale.ROOT, ind + "%2$s%n", "", recordStr);
 
         if (record instanceof EscherContainerRecord) {
             walkEscherDDF((indent + 3), pos + 8, (int) atomLen);
@@ -273,7 +273,7 @@ public final class SlideShowDumper {
             recordLen = (int) atomLen + 8;
             record.fillFields(contents, 0, erf);
             if (!(record instanceof EscherTextboxRecord)) {
-                out.println(String.format(Locale.ROOT, ind + "%2$s", "", "** Really a msofbtClientTextbox !"));
+                out.printf(Locale.ROOT, ind + "%2$s%n", "", "** Really a msofbtClientTextbox !");
             }
         }
 
@@ -315,10 +315,10 @@ public final class SlideShowDumper {
         long atomlen = LittleEndian.getUInt(docstream, pos + 4);
 
         String fmt = ind + "At position %2$d ($2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x)";
-        out.println(String.format(Locale.ROOT, fmt, "", pos, type, atomlen));
+        out.printf(Locale.ROOT, (fmt) + "%n", "", pos, type, atomlen);
 
         String typeName = RecordTypes.forTypeID((short) type).name();
-        out.println(String.format(Locale.ROOT, ind + "%2$s", "That's an Escher Record: ", typeName));
+        out.printf(Locale.ROOT, ind + "%2$s%n", "That's an Escher Record: ", typeName);
 
         // Record specific dumps
         if (type == 61453L) {