src/share/jaxws_classes/com/sun/xml/internal/ws/util/ASCIIUtility.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, 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
25 25
26 package com.sun.xml.internal.ws.util; 26 package com.sun.xml.internal.ws.util;
27 27
28 import java.io.InputStream; 28 import java.io.InputStream;
29 import java.io.IOException; 29 import java.io.IOException;
30 import java.io.ByteArrayInputStream;
31 import java.io.ByteArrayOutputStream;
32 import java.io.OutputStream; 30 import java.io.OutputStream;
33 31
34 /** 32 /**
35 * Copied from mail.jar. 33 * Copied from mail.jar.
36 */ 34 */
119 theChars[i++] = (char)(b[j++]&0xff); 117 theChars[i++] = (char)(b[j++]&0xff);
120 118
121 return new String(theChars); 119 return new String(theChars);
122 } 120 }
123 121
124 public static byte[] getBytes(String s) {
125 char [] chars= s.toCharArray();
126 int size = chars.length;
127 byte[] bytes = new byte[size];
128
129 for (int i = 0; i < size;)
130 bytes[i] = (byte) chars[i++];
131 return bytes;
132 }
133
134 public static byte[] getBytes(InputStream is) throws IOException {
135 ByteArrayBuffer bab = new ByteArrayBuffer();
136 bab.write(is);
137 return bab.toByteArray();
138 }
139
140 public static void copyStream(InputStream is, OutputStream out) throws IOException { 122 public static void copyStream(InputStream is, OutputStream out) throws IOException {
141 int size = 1024; 123 int size = 1024;
142 byte[] buf = new byte[size]; 124 byte[] buf = new byte[size];
143 int len; 125 int len;
144 126

mercurial