Package java.io

Examples of java.io.UTFDataFormatException


                break;
            case 12:
            case 13:
                pos+=2;
                if(pos>length)
                    throw new UTFDataFormatException("bad string");
                c2=(int) buf[pos-1];
                if((c2&0xC0)!=0x80)
                    throw new UTFDataFormatException("bad string");
                characters[count++]=(char) (((c&0x1F)<<6)|(c2&0x3F));
                break;
            case 14:
                pos+=3;
                if(pos>length)
                    throw new UTFDataFormatException("bad string");
                c2=(int) buf[pos-2];
                c3=(int) buf[pos-1];
                if(((c2&0xC0)!=0x80)||((c3&0xC0)!=0x80))
                    throw new UTFDataFormatException("bad string");
                characters[count++]=(char) (((c&0x0F)<<12)|((c2&0x3F)<<6)|((c3&0x3F)<<0));
                break;
            default:
                throw new UTFDataFormatException("bad string");
            }
        }
        return new String(characters,0,count);
    }
View Full Code Here


                    case 12:
                    case 13:
                        /* 110x xxxx 10xx xxxx */
                        count += 2;
                        if (count > utflen) {
                            throw new UTFDataFormatException();
                        }
                        char2 = bytearr[count - 1];
                        if ((char2 & 0xC0) != 0x80) {
                            throw new UTFDataFormatException();
                        }
                        str.append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
                        break;
                    case 14:
                        /* 1110 xxxx 10xx xxxx 10xx xxxx */
                        count += 3;
                        if (count > utflen) {
                            throw new UTFDataFormatException();
                        }
                        char2 = bytearr[count - 2]; //TODO diff: Sun code
                        char3 = bytearr[count - 1]; //TODO diff: Sun code
                        if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
                            throw new UTFDataFormatException();
                        }
                        str.append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
                        break;
                    default :
                        /* 10xx xxxx, 1111 xxxx */
                        throw new UTFDataFormatException();
                }
            }
            // The number of chars produced may be less than utflen
            return new String(str);
        } else {
View Full Code Here

                    offset += 3;
                } else {
                    // This shouldn't happen, as the data is coming from the
                    // store and is supposed to be well-formed.
                    // If it happens, fail and print some internal information.
                    throw new UTFDataFormatException("Invalid UTF-8 encoding: "
                            + Integer.toHexString(c) + ", charCount=" +
                            charCount + ", offset=" + offset);
                }
                charCount++;
            }
View Full Code Here

    while (count < utfSize) {
      if ((out[s] = (char) buf[offset + count++]) < '\u0080')
        s++;
      else if (((a = out[s]) & 0xe0) == 0xc0) {
        if (count >= utfSize)
          throw new UTFDataFormatException(Msg.getString("K0062",
              count));
        int b = buf[count++];
        if ((b & 0xC0) != 0x80)
          throw new UTFDataFormatException(Msg.getString("K0062",
              (count - 1)));
        out[s++] = (char) (((a & 0x1F) << 6) | (b & 0x3F));
      } else if ((a & 0xf0) == 0xe0) {
        if (count + 1 >= utfSize)
          throw new UTFDataFormatException(Msg.getString("K0063",
              (count + 1)));
        int b = buf[count++];
        int c = buf[count++];
        if (((b & 0xC0) != 0x80) || ((c & 0xC0) != 0x80))
          throw new UTFDataFormatException(Msg.getString("K0064",
              (count - 2)));
        out[s++] = (char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F));
      } else {
        throw new UTFDataFormatException(Msg.getString("K0065",
            (count - 1)));
      }
    }
    return new String(out, 0, s);
  }
View Full Code Here

    /** Throws an exception for expected byte. */
    private void expectedByte(int position, int count)
        throws UTFDataFormatException {

        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.expectedByte",
             Integer.toString(position),
             Integer.toString(count)));

    } // expectedByte(int,int,int)
View Full Code Here

    /** Throws an exception for invalid byte. */
    private void invalidByte(int position, int count, int c)
        throws UTFDataFormatException {

        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.invalidByte",
             Integer.toString(position),
             Integer.toString(count)));
    } // invalidByte(int,int,int,int)
View Full Code Here

    } // invalidByte(int,int,int,int)

    /** Throws an exception for invalid surrogate bits. */
    private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
       
        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.invalidHighSurrogate",
             Integer.toHexString(uuuuu)));
    } // invalidSurrogate(int)
View Full Code Here

    /** Throws an exception for expected byte. */
    private void expectedByte(int position, int count)
        throws UTFDataFormatException {

        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.expectedByte",
             Integer.toString(position),
             Integer.toString(count)));

    } // expectedByte(int,int,int)
View Full Code Here

    /** Throws an exception for invalid byte. */
    private void invalidByte(int position, int count, int c)
        throws UTFDataFormatException {

        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.invalidByte",
             Integer.toString(position),
             Integer.toString(count)));
    } // invalidByte(int,int,int,int)
View Full Code Here

    } // invalidByte(int,int,int,int)

    /** Throws an exception for invalid surrogate bits. */
    private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
       
        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.invalidHighSurrogate",
             Integer.toHexString(uuuuu)));
    } // invalidSurrogate(int)
View Full Code Here

TOP

Related Classes of java.io.UTFDataFormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.