]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Remove unused code
authorJeremias Maerki <jeremias@apache.org>
Fri, 4 Jul 2003 20:12:59 +0000 (20:12 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 4 Jul 2003 20:12:59 +0000 (20:12 +0000)
Use IO methods from Commons IO

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196601 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/InMemoryStreamCache.java
src/java/org/apache/fop/pdf/TempFileStreamCache.java

index ab464184f59c7d1a16f383da56c2a8b0d39ad4b2..6c8710607a003608fbc211ef056cb77267c24a0b 100644 (file)
@@ -51,7 +51,6 @@
 package org.apache.fop.pdf;
 
 import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
 import java.io.OutputStream;
 import java.io.IOException;
 
@@ -105,32 +104,6 @@ public class InMemoryStreamCache implements StreamCache {
         getOutputStream().write(data);
     }
     
-    /**
-     * Filter the cache with the supplied PDFFilter.
-     * @param filter the filter to apply
-     * @throws IOException if an IO error occurs
-     */
-    public void applyFilter(PDFFilter filter) throws IOException {
-        if (output == null) {
-            return;
-        }
-
-        output.close();
-
-        // make inputstream from copy of outputted bytes
-        int size = getSize();
-        ByteArrayInputStream input =
-          new ByteArrayInputStream(output.toByteArray());
-
-        // reset output
-        output.reset();
-
-        // run filter
-        filter.encode(input, output, size);
-        input.close();
-        output.close();
-    }
-
     /**
      * Outputs the cached bytes to the given stream.
      * @param out the output stream to write to
index e02a65c005d3247d4cdbccd45bcd04cf9df2182b..a387b9a1ba6726a8e5215f6259ed757cc5bf9c52 100644 (file)
  */ 
 package org.apache.fop.pdf;
 
-import org.apache.fop.util.StreamUtilities;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+// Java
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
 import java.io.File;
 
+//Commons
+import org.apache.commons.io.IOUtil;
+
 /**
  * StreamCache implementation that uses temporary files rather than heap.
  */
@@ -96,8 +94,8 @@ public class TempFileStreamCache implements StreamCache {
      */
     public OutputStream getOutputStream() throws IOException {
         if (output == null) {
-            output = new BufferedOutputStream(
-                       new FileOutputStream(tempFile));
+            output = new java.io.BufferedOutputStream(
+                       new java.io.FileOutputStream(tempFile));
         }
         return output;
     }
@@ -109,38 +107,6 @@ public class TempFileStreamCache implements StreamCache {
         getOutputStream().write(data);
     }
     
-    /**
-     * Filter the cache with the supplied PDFFilter.
-     *
-     * @param filter the filter to apply
-     * @throws IOException if there is an IO error
-     */
-    public void applyFilter(PDFFilter filter) throws IOException {
-        if (output == null) {
-            return;
-        }
-
-        output.close();
-        output = null;
-
-        // need a place to put results
-        File newTempFile =
-          File.createTempFile("org.apache.fop.pdf.StreamCache-",
-                              ".temp");
-        newTempFile.deleteOnExit();
-
-        // filter may not be buffered
-        BufferedInputStream input =
-          new BufferedInputStream(new FileInputStream(tempFile));
-        BufferedOutputStream output = new BufferedOutputStream(
-                                        new FileOutputStream(newTempFile));
-        filter.encode(input, output, (int) tempFile.length());
-        input.close();
-        output.close();
-        tempFile.delete();
-        tempFile = newTempFile;
-    }
-
     /**
      * Outputs the cached bytes to the given stream.
      *
@@ -158,7 +124,7 @@ public class TempFileStreamCache implements StreamCache {
 
         // don't need a buffer because streamCopy is buffered
         InputStream input = new java.io.FileInputStream(tempFile);
-        final long bytesCopied = StreamUtilities.streamCopy(input, out);
+        final long bytesCopied = IOUtil.copy(input, out);
         input.close();
         return (int)bytesCopied;
     }