1 34 35 package com.micronova.util; 36 37 38 39 public class ByteArrayCharSequence implements CharSequence 40 { 41 protected byte[] _array; 42 43 public ByteArrayCharSequence(byte[] array) 44 { 45 _array = array; 46 } 47 48 public char charAt(int index) 49 { 50 return (char)_array[index]; 51 } 52 53 public int length() 54 { 55 return _array.length; 56 } 57 58 public CharSequence subSequence(int start, int end) 59 { 60 int subLength = end - start; 61 62 byte[] subArray = new byte[subLength]; 63 64 System.arraycopy(_array, start, subArray, 0, subLength); 65 66 return new ByteArrayCharSequence(subArray); 67 } 68 69 public String toString() 70 { 71 try 72 { 73 return new String (_array, "iso-8859-1"); 74 } 75 catch (Exception e) 76 { 77 return null; 78 } 79 } 80 } 81 82 | Popular Tags |