37
37
import java .io .FileNotFoundException ;
38
38
import java .io .FileOutputStream ;
39
39
import java .io .IOException ;
40
- import java .io . UnsupportedEncodingException ;
40
+ import java .nio . charset . StandardCharsets ;
41
41
import java .util .ArrayList ;
42
42
import java .util .Date ;
43
43
import java .util .List ;
@@ -266,7 +266,7 @@ public byte[] getPDFBytes() {
266
266
xref [xref .length - 1 ] = bos .size ();
267
267
// write the xref table
268
268
bos .write (toBytes ("xref\n " ));
269
- bos .write (toBytes ("0 " + String . valueOf ( this .nextNumber )
269
+ bos .write (toBytes ("0 " + this .nextNumber
270
270
+ "\n " ));
271
271
bos .write (toBytes ("0000000000 65535 f \n " ));
272
272
for (int i = 0 ; i < this .nextNumber - 1 ; i ++) {
@@ -284,8 +284,7 @@ public byte[] getPDFBytes() {
284
284
trailer .put ("/Info" , this .info );
285
285
bos .write (trailer .toPDFBytes ());
286
286
bos .write (toBytes ("startxref\n " ));
287
- bos .write (toBytes (String .valueOf (xref [this .nextNumber - 1 ])
288
- + "\n " ));
287
+ bos .write (toBytes (xref [this .nextNumber - 1 ] + "\n " ));
289
288
bos .write (toBytes ("%%EOF" ));
290
289
} catch (IOException ex ) {
291
290
throw new RuntimeException (ex );
@@ -328,11 +327,7 @@ public void writeToFile(File f) {
328
327
*/
329
328
private byte [] toBytes (String s ) {
330
329
byte [] result = null ;
331
- try {
332
- result = s .getBytes ("US-ASCII" );
333
- } catch (UnsupportedEncodingException ex ) {
334
- throw new RuntimeException (ex );
335
- }
330
+ result = s .getBytes (StandardCharsets .US_ASCII );
336
331
return result ;
337
332
}
338
333
0 commit comments