jdk/src/share/classes/java/lang/StringCoding.java
changeset 42 6c846a8c97d3
parent 41 dfebd2609e77
child 715 f16baef3a20e
equal deleted inserted replaced
41:dfebd2609e77 42:6c846a8c97d3
   192         return sd.decode(ba, off, len);
   192         return sd.decode(ba, off, len);
   193     }
   193     }
   194 
   194 
   195     static char[] decode(Charset cs, byte[] ba, int off, int len) {
   195     static char[] decode(Charset cs, byte[] ba, int off, int len) {
   196         StringDecoder sd = new StringDecoder(cs, cs.name());
   196         StringDecoder sd = new StringDecoder(cs, cs.name());
   197         byte[] b = Arrays.copyOf(ba, ba.length);
   197         return sd.decode(Arrays.copyOfRange(ba, off, off + len), 0, len);
   198         return sd.decode(b, off, len);
       
   199     }
   198     }
   200 
   199 
   201     static char[] decode(byte[] ba, int off, int len) {
   200     static char[] decode(byte[] ba, int off, int len) {
   202         String csn = Charset.defaultCharset().name();
   201         String csn = Charset.defaultCharset().name();
   203         try {
   202         try {
   291         return se.encode(ca, off, len);
   290         return se.encode(ca, off, len);
   292     }
   291     }
   293 
   292 
   294     static byte[] encode(Charset cs, char[] ca, int off, int len) {
   293     static byte[] encode(Charset cs, char[] ca, int off, int len) {
   295         StringEncoder se = new StringEncoder(cs, cs.name());
   294         StringEncoder se = new StringEncoder(cs, cs.name());
   296         char[] c = Arrays.copyOf(ca, ca.length);
   295         return se.encode(Arrays.copyOfRange(ca, off, off + len), 0, len);
   297         return se.encode(c, off, len);
       
   298     }
   296     }
   299 
   297 
   300     static byte[] encode(char[] ca, int off, int len) {
   298     static byte[] encode(char[] ca, int off, int len) {
   301         String csn = Charset.defaultCharset().name();
   299         String csn = Charset.defaultCharset().name();
   302         try {
   300         try {