"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

COSStream.java  (pdfbox-2.0.23-src):COSStream.java  (pdfbox-2.0.24-src)
skipping to change at line 19 skipping to change at line 19
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.pdfbox.cos; package org.apache.pdfbox.cos;
import java.io.ByteArrayOutputStream;
import java.io.Closeable; import java.io.Closeable;
import java.io.FilterOutputStream; import java.io.FilterOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
skipping to change at line 394 skipping to change at line 393
return toTextString(); return toTextString();
} }
/** /**
* Returns the contents of the stream as a PDF "text string". * Returns the contents of the stream as a PDF "text string".
* *
* @return the text string representation of this stream. * @return the text string representation of this stream.
*/ */
public String toTextString() public String toTextString()
{ {
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream input = null; InputStream input = null;
byte[] array;
try try
{ {
input = createInputStream(); input = createInputStream();
IOUtils.copy(input, out); array = IOUtils.toByteArray(input);
} }
catch (IOException e) catch (IOException e)
{ {
LOG.debug("An exception occurred trying to get the content - returni ng empty string instead", e);
return ""; return "";
} }
finally finally
{ {
IOUtils.closeQuietly(input); IOUtils.closeQuietly(input);
} }
COSString string = new COSString(out.toByteArray()); COSString string = new COSString(array);
return string.getString(); return string.getString();
} }
@Override @Override
public Object accept(ICOSVisitor visitor) throws IOException public Object accept(ICOSVisitor visitor) throws IOException
{ {
return visitor.visitFromStream(this); return visitor.visitFromStream(this);
} }
@Override @Override
 End of changes. 6 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)