Package java.nio.charset

Examples of java.nio.charset.MalformedInputException


      /**While detecting the charset, if head is not closed inside
       * the interval which we are examining, something is wrong, and it's
       * possible that the file has been given a freakishly large head, so
       * that we'll miss a charset declaration.*/
      if(onlyDetectingCharset && openElements.contains("head")) {
        throw new MalformedInputException(1024*64);
      }
      //Writing the remaining tags for XHTML if any
      if(getisXHTML())
      {
        while(openElements.size()>0)
View Full Code Here


        length = bytesFromUTF8[aByte];

        switch (length) {
        case 0: // check for ASCII
          if (leadByte > 0x7F)
            throw new MalformedInputException(count);
          break;
        case 1:
          if (leadByte < 0xC2 || leadByte > 0xDF)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        case 2:
          if (leadByte < 0xE0 || leadByte > 0xEF)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        case 3:
          if (leadByte < 0xF0 || leadByte > 0xF4)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        default:
          // too long! Longest valid UTF-8 is 4 bytes (lead + three)
          // or if < 0 we got a trail byte in the lead byte position
          throw new MalformedInputException(count);
        } // switch (length)
        break;

      case TRAIL_BYTE_1:
        if (leadByte == 0xF0 && aByte < 0x90)
          throw new MalformedInputException(count);
        if (leadByte == 0xF4 && aByte > 0x8F)
          throw new MalformedInputException(count);
        if (leadByte == 0xE0 && aByte < 0xA0)
          throw new MalformedInputException(count);
        if (leadByte == 0xED && aByte > 0x9F)
          throw new MalformedInputException(count);
        // falls through to regular trail-byte test!!
      case TRAIL_BYTE:
        if (aByte < 0x80 || aByte > 0xBF)
          throw new MalformedInputException(count);
        if (--length == 0) {
          state = LEAD_BYTE;
        } else {
          state = TRAIL_BYTE;
        }
View Full Code Here

            if (cr.isMalformed()) {
                // Move the tail bytes to the head
                int tailLength = bb.remaining();
                if (tailLength >= MALFORMED_INPUT_MAX_LENGTH) {
                    // We only expect the bytes of one character to be broken
                    throw new MalformedInputException(tailLength);
                }
            }
            bb.compact();
        } else {
            bb.clear();
View Full Code Here

            // Process the buffered bytes
            decodeBuffer(true);
            if (bb.position() > 0) {
                // There are still malformed input remaining, even though we
                // are going to write a string. This should not happen.
                throw new MalformedInputException(bb.position());
            }
        }
        // Process the string without encoding/decoding overhead
        char[] content = s.toCharArray();
        int offset = 0;
View Full Code Here

        length = bytesFromUTF8[aByte];

        switch (length) {
        case 0: // check for ASCII
          if (leadByte > 0x7F)
            throw new MalformedInputException(count);
          break;
        case 1:
          if (leadByte < 0xC2 || leadByte > 0xDF)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        case 2:
          if (leadByte < 0xE0 || leadByte > 0xEF)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        case 3:
          if (leadByte < 0xF0 || leadByte > 0xF4)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        default:
          // too long! Longest valid UTF-8 is 4 bytes (lead + three)
          // or if < 0 we got a trail byte in the lead byte position
          throw new MalformedInputException(count);
        } // switch (length)
        break;

      case TRAIL_BYTE_1:
        if (leadByte == 0xF0 && aByte < 0x90)
          throw new MalformedInputException(count);
        if (leadByte == 0xF4 && aByte > 0x8F)
          throw new MalformedInputException(count);
        if (leadByte == 0xE0 && aByte < 0xA0)
          throw new MalformedInputException(count);
        if (leadByte == 0xED && aByte > 0x9F)
          throw new MalformedInputException(count);
        // falls through to regular trail-byte test!!
      case TRAIL_BYTE:
        if (aByte < 0x80 || aByte > 0xBF)
          throw new MalformedInputException(count);
        if (--length == 0) {
          state = LEAD_BYTE;
        } else {
          state = TRAIL_BYTE;
        }
View Full Code Here

            if (cr.isMalformed()) {
                // Move the tail bytes to the head
                int tailLength = bb.remaining();
                if (tailLength >= MALFORMED_INPUT_MAX_LENGTH) {
                    // We only expect the bytes of one character to be broken
                    throw new MalformedInputException(tailLength);
                }
            }
            bb.compact();
        } else {
            bb.clear();
View Full Code Here

            // Process the buffered bytes
            decodeBuffer(true);
            if (bb.position() > 0) {
                // There are still malformed input remaining, even though we
                // are going to write a string. This should not happen.
                throw new MalformedInputException(bb.position());
            }
        }
        // Process the string without encoding/decoding overhead
        char[] content = s.toCharArray();
        int offset = 0;
View Full Code Here

        length = bytesFromUTF8[aByte];

        switch (length) {
        case 0: // check for ASCII
          if (leadByte > 0x7F)
            throw new MalformedInputException(count);
          break;
        case 1:
          if (leadByte < 0xC2 || leadByte > 0xDF)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        case 2:
          if (leadByte < 0xE0 || leadByte > 0xEF)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        case 3:
          if (leadByte < 0xF0 || leadByte > 0xF4)
            throw new MalformedInputException(count);
          state = TRAIL_BYTE_1;
          break;
        default:
          // too long! Longest valid UTF-8 is 4 bytes (lead + three)
          // or if < 0 we got a trail byte in the lead byte position
          throw new MalformedInputException(count);
        } // switch (length)
        break;

      case TRAIL_BYTE_1:
        if (leadByte == 0xF0 && aByte < 0x90)
          throw new MalformedInputException(count);
        if (leadByte == 0xF4 && aByte > 0x8F)
          throw new MalformedInputException(count);
        if (leadByte == 0xE0 && aByte < 0xA0)
          throw new MalformedInputException(count);
        if (leadByte == 0xED && aByte > 0x9F)
          throw new MalformedInputException(count);
        // falls through to regular trail-byte test!!
      case TRAIL_BYTE:
        if (aByte < 0x80 || aByte > 0xBF)
          throw new MalformedInputException(count);
        if (--length == 0) {
          state = LEAD_BYTE;
        } else {
          state = TRAIL_BYTE;
        }
View Full Code Here

            if (cr.isMalformed()) {
                // Move the tail bytes to the head
                int tailLength = bb.remaining();
                if (tailLength >= MALFORMED_INPUT_MAX_LENGTH) {
                    // We only expect the bytes of one character to be broken
                    throw new MalformedInputException(tailLength);
                }
            }
            bb.compact();
        } else {
            bb.clear();
View Full Code Here

            // Process the buffered bytes
            decodeBuffer(true);
            if (bb.position() > 0) {
                // There are still malformed input remaining, even though we
                // are going to write a string. This should not happen.
                throw new MalformedInputException(bb.position());
            }
        }
        // Process the string without encoding/decoding overhead
        char[] content = s.toCharArray();
        int offset = 0;
View Full Code Here

TOP

Related Classes of java.nio.charset.MalformedInputException

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.