jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/packaging/mime/util/ASCIIUtility.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
139 * buffer reallocation just to get the array of an exact size. |
139 * buffer reallocation just to get the array of an exact size. |
140 * Unless you absolutely need the exact size array, don't use this. |
140 * Unless you absolutely need the exact size array, don't use this. |
141 * Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}. |
141 * Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}. |
142 */ |
142 */ |
143 public static byte[] getBytes(InputStream is) throws IOException { |
143 public static byte[] getBytes(InputStream is) throws IOException { |
144 ByteOutputStream bos = new ByteOutputStream(); |
144 ByteOutputStream bos = null; |
145 try { |
145 try { |
|
146 bos = new ByteOutputStream(); |
146 bos.write(is); |
147 bos.write(is); |
147 } finally { |
148 } finally { |
|
149 if (bos != null) |
|
150 bos.close(); |
148 is.close(); |
151 is.close(); |
149 } |
152 } |
150 return bos.toByteArray(); |
153 return bos.toByteArray(); |
151 } |
154 } |
152 } |
155 } |