You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/08/19 16:42:08 UTC
svn commit: r1865483 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
Author: tilman
Date: Mon Aug 19 16:42:08 2019
New Revision: 1865483
URL: http://svn.apache.org/viewvc?rev=1865483&view=rev
Log:
PDFBOX-4071: avoid throwing RuntimeException
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java?rev=1865483&r1=1865482&r2=1865483&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java Mon Aug 19 16:42:08 2019
@@ -92,19 +92,10 @@ public final class COSString extends COS
{
// UTF-16BE encoded string with a leading byte order marker
byte[] data = text.getBytes(Charsets.UTF_16BE);
- ByteArrayOutputStream out = new ByteArrayOutputStream(data.length + 2);
- out.write(0xFE); // BOM
- out.write(0xFF); // BOM
- try
- {
- out.write(data);
- }
- catch (IOException e)
- {
- // should never happen
- throw new RuntimeException(e);
- }
- bytes = out.toByteArray();
+ bytes = new byte[data.length + 2];
+ bytes[0] = (byte) 0xFE;
+ bytes[1] = (byte) 0xFF;
+ System.arraycopy(data, 0, bytes, 2, data.length);
}
}