1 31 package org.pdfbox.filter; 32 33 import java.io.IOException ; 34 import java.io.InputStream ; 35 import java.io.OutputStream ; 36 37 import org.pdfbox.io.ASCII85InputStream; 38 import org.pdfbox.io.ASCII85OutputStream; 39 40 import org.pdfbox.cos.COSDictionary; 41 42 48 public class ASCII85Filter implements Filter 49 { 50 59 public void decode( InputStream compressedData, OutputStream result, COSDictionary options ) throws IOException 60 { 61 ASCII85InputStream is = null; 62 try 63 { 64 is = new ASCII85InputStream(compressedData); 65 byte[] buffer = new byte[1024]; 66 int amountRead = 0; 67 while( (amountRead = is.read( buffer, 0, 1024) ) != -1 ) 68 { 69 result.write(buffer, 0, amountRead); 70 } 71 result.flush(); 72 } 73 finally 74 { 75 if( is != null ) 76 { 77 is.close(); 78 } 79 } 80 } 81 82 91 public void encode( InputStream rawData, OutputStream result, COSDictionary options ) throws IOException 92 { 93 ASCII85OutputStream os = new ASCII85OutputStream(result); 94 byte[] buffer = new byte[1024]; 95 int amountRead = 0; 96 while( (amountRead = rawData.read( buffer, 0, 1024 )) != -1 ) 97 { 98 os.write( buffer, 0, amountRead ); 99 } 100 os.close(); 101 result.flush(); 102 } 103 } | Popular Tags |